>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 1 is the case, the ES6 spec should match reality by reverting the change 
introduced in ES5.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to