Symbol.hasInstance and [[Get]] vs [[GetOwnProperty]]
Claude Pache
claude.pache at gmail.com
Wed Aug 24 05:49:29 UTC 2016
> Le 24 août 2016 à 03:35, /#!/JoePea <joe at trusktr.io> a écrit :
>
> > if you want to revert to the default behavior set the value of B or C’s [Symbol.hasInstance] own property to undefined.
>
> That just causes errors. In my environment (Babel),
>
> ```js
> Object.defineProperty(SomeClass, Symbol.hasInstance, {
> value: undefined
> })
>
> // ...
>
> someClass instanceof SomeClass // error
> ```
>
> results in
>
> ```js
> Uncaught TypeError: Cannot read property 'call' of undefined
> ```
>
If that’s the case, it's a bug (or limitation?) of Babel, as the spec is clear, see: https://tc39.github.io/ecma262/#sec-instanceofoperator
Also, reading the message of your TypeError, I wonder if Babel may also fail unexpectedly in case SomeClass does not inherit the standard `Function#call`, as in: ```class SomeClass { static call() { throw "Pwnd!" } }```.
—Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160824/14d29eb9/attachment.html>
More information about the es-discuss
mailing list