RESOLVED INVALID 125501
`Function.prototype.apply` & `Function.prototype.call` with `undefined` or `null` as `thisArg`
https://bugs.webkit.org/show_bug.cgi?id=125501
Summary `Function.prototype.apply` & `Function.prototype.call` with `undefined` or `n...
Mathias Bynens
Reported 2013-12-10 05:16:57 PST
From <http://ecma-international.org/ecma-262/5.1/#sec-15.3.4.3> and <http://ecma-international.org/ecma-262/5.1/#sec-15.3.4.4>: 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. It seems like modern engines still have the ES3 behavior: function foo() { console.log(this); return this; }; foo.call(undefined) === undefined; // `false`, expected `true` I’ve tested this in Spidermonkey/Firefox, Carakan/PrestOpera, JSC/Safari, and v8/Chrome. They all show FAIL in this test case: data:text/html,<script>function foo() { console.log(this); return this; }; document.write(foo.call(undefined) === undefined %3F 'PASS' %3A 'FAIL');</script> Is this… 1. a wilful violation of the ES5 spec for back-compat reasons, or… 2. is it just an oversight that this never got implemented, or… 3. am I misreading the spec? If 2 is the case, please fix this :)
Attachments
Mathias Bynens
Comment 1 2013-12-10 05:30:02 PST
Note You need to log in before you can comment on or make changes to this bug.