0

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'
})
1
  • i wouldn't say it's a duplicate, OP is asking about chaining function calls, and which context has precedence Commented Dec 23, 2015 at 11:02

1 Answer 1

0

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.