Following code gives the output {name:'xyz'}.
How do we know what this points to when both call and bind are used?
var factoryFunc = function() {
console.log(this);
}.bind({
'name': 'xyz'
})
factoryFunc.call({
'name': 'abc'
})
-
i wouldn't say it's a duplicate, OP is asking about chaining function calls, and which context has precedenceBojana Šekeljić– Bojana Šekeljić2015年12月23日 11:02:30 +00:00Commented Dec 23, 2015 at 11:02
1 Answer 1
A bound function will have its this value immutable. So in your case the XYZ object will be pointed.
I will update this answer when I get to my pc
Sign up to request clarification or add additional context in comments.
Comments
lang-js