In this commit there is a change I cannot explain
deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
becomes
deferred.done( arguments ).fail( arguments );
AFAIK, when you invoke a function as a member of some object like obj.func(), inside the function this is bound to obj, so there would be no use invoking a function through apply() just to bound this to obj. Instead, according to the comments, this was required because of some preceding $.Callbacks.add implementation.
My doubt is not about jQuery, but about the Javascript language itself: when you invoke a function like obj.func(), how can it be that inside func() the this keyword is not bound to obj?
Well, the only way this is possible is if
obj.funcreferences aboundfunction, then it doesn’t matter how you call it. In that case it doesn’t matter how you call the function, whether you doobj.func(),func(),func.call({}),func.apply({})doesn’t matter at all. I’m not sure how the commit is related to this, however.To clarify, I am answering the quoted question interpreted as:
Given a call signature like:
obj.func(), how is it possible thatthisis notobjinside the called function for the call?