Symbol.hasInstance and [[Get]] vs [[GetOwnProperty]]

/#!/JoePea joe at trusktr.io
Wed Aug 24 17:38:20 UTC 2016


Well, after looking at "Runtime Semantics: InstanceofOperator(O, C)" in the
spec that you linked to, the mere fact that `@@hasInstance` can be
undefined in which case inheritance is ignored completely goes against...
inheritance.

So, this proves that we can make the spec be anything we wish it to be (as
currently it doesn't follow pure prototypal inheritance), so we could
easily choose to use `[[GetOwnProperty]]` without inheritance if we wanted
to, and in my opinion that is much better.

*/#!/*JoePea

On Tue, Aug 23, 2016 at 10:59 PM, Claude Pache <claude.pache at gmail.com>
wrote:

> ```js
> Uncaught TypeError: Cannot read property 'call' of undefined
> ```
>
>
> (...)
>
>
> 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!"
> } }```.
>
>
> Correction: The potential issue I was thinking of, is when
> `SomeClass[Symbol.hasInstance]` does not inherit the standard
> `Function#call`:
>
> ```js
> class SomeClass {
>     static [Symbol.hasInstance]() { /* foo */ }
> }
> SomeClass[Symbol.hasInstance].call = function () { throw "Pwnd!" }
> ```
>
> which is quite a corner case.
>
> —Claude
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160824/f0ecb57f/attachment.html>


More information about the es-discuss mailing list