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'
})
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'
})
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