// example A (works)
foo(function() {
myObj.save();
});
// example B (doesn't work)
foo(myObj.save);
// example C (works)
foo(myObj.save.bind(myObj));
Why is the this
reference correct when myObj.save
is called in example A
, but not in example B
?
I can force this
to be correct by using bind
, but what is happening in example A
that is different from example B
?
I don't understand why this
would be different.