Determining the this binding for an executing function requires finding the direct call-site of that function. Once examined, four rules can be applied to the call-site, in this order of precedence:
-
Called with new? Use the newly constructed object.
-
Called with call or apply (or bind)? Use the specified object.
-
Called with a context object owning the call? Use that context object.
-
Default: undefined in strict mode, global object otherwise.