Hi,
Consider the following test case:
```html
<script>
function returnThisValue() { "use strict"; return this }
Object.defineProperties(Object.prototype, {
getThisValue: { value: returnThisValue, configurable: true }
, thisValue: { get: returnThisValue, configurable: true }
})
window.alert(getThisValue() + "\n" + thisValue)
</script>
```
What should be displayed? According to my tests:
* Firefox [1], Chrome and Edge:
undefined
[object Window]
[1]: (For Firefox, use v.46+ in order to avoid interference with this
recently-solved bug: https://bugzilla.mozilla.org/show_bug.cgi?id=603201
<https://bugzilla.mozilla.org/show_bug.cgi?id=603201>)
* Safari (although I get contradictory results with further tests involving
`__proto__`):
undefined
undefined
* ECMA-262, if I read correctly:
undefined
[object Window]
The relevant steps in the spec are:
* for `getThisArg()` : [12.3.1.4.1] step 4.b.ii, where `refEnv` is an Object
Environment Record associated to the global object; `refEnv.WithBaseObject()`
will be `undefined`.
* for `thisArg`: [8.1.1.2.6] step 5, where `bindings` is the global object and
`N` is `"thisArg"`.
[12.3.1.4.1]:
https://tc39.github.io/ecma262/#sec-function-calls-runtime-semantics-evaluation
[8.1.1.2.6]:
https://tc39.github.io/ecma262/#sec-object-environment-records-getbindingvalue-n-s
Is it an intentional and/or desired behaviour?
In practice it has an influence on what a bare `__proto__` should evaluate to.
—Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss