call and apply
allen at wirfs-brock.com
Fri May 3 10:18:01 PDT 2013
On May 3, 2013, at 5:33 AM, raul mihaila wrote:
> In section 22.214.171.124 Function.prototype.apply (thisArg, argArray) (page 119 of Ecma-262, Edition 5.1) there's this note:
> 'The thisArg value is passed without modification as the this value. This is a change from Edition 3, where a undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value.' From this I understand that this is happening in both non-strict mode and strict mode.
This is describing the internal behavior of the apply function. Note that built-ins like apply are neither strict or non-strict as they aren't specified via ECMAScript code. They always operate the same regardless of which mode code called them.
> But in Annex C, one of the bullets says (page 235):
> 'If this is evaluated within strict mode code, then the this value is not coerced to an object. A this value of null or undefined is not converted to the global object and primitive values are not converted to wrapper objects. The this value passed via a function call (including calls made using Function.prototype.apply and Function.prototype.call) do not coerce the passed this value to an object (10.4.3, 11.1.1, 126.96.36.199, 188.8.131.52).' From this I understand that the coercion occurs only in non-strict mode (like in Firefox).
Annex C is specifically about strict mode. Annex E gives a more general description that applies to both modes.
> Is it possible to make this clearer in the next edition, please?
Feel free to file a bug with suggested changes at bugs.ecmascript.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss