Fixing the associativity / precedence of the instanceof operator

Charles Pick charles at
Mon Aug 25 03:40:52 PDT 2014

Hello, forgive me if this has come up before, I couldn't find any
discussions via Google.

One regular, annoying mistake I see people making is combining the `!`
operator with `instanceof`:

    if (!foo instanceof Foo) { ... }

of course, this must be written with extra parentheses:

    if (!(foo instanceof Foo)) { ... }

My question is, why? There are no circumstances where the developer
*intended* to write the first version, it's a typo and will always evaluate
to false, even when using Boolean. Therefore would it be possible to fix
the precedence so that the first version is parsed the same way as the


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list