Strawman proposal: new `is` operator

Brendan Eich brendan at
Mon Aug 25 18:56:51 PDT 2014

Isiah Meadows wrote:
> Cc the list...
> On Aug 25, 2014 6:06 PM, "Isiah Meadows" <impinball at 
> <mailto:impinball at>> wrote:
>     There really shouldn't be any sort of object construction needed
>     to check types like this. `isa` may be better, anyways, but I
>     still find that requirement to build and destroy an object to
>     check somewhat counterproductive.

What object is built and destroyed?

Note that for primitive types no wrapper need be created just to call a 
method, in general for JIT-optimized code, and definitely for strict 
mode code.

>     Andrea gets what I'm talking about. Also, another (possibly
>     separate) proposal would be to make cases like `"foo" instanceof
>     String" === true` instead of their current behavior, throwing a
>     TypeError. (I believe...I'm on a phone, not a PC where I can test.
>     Correct me if I'm wrong.)

(Your phone doesn't have a browser with a console? :-P)

js> "hi" instanceof String
js> 42 instanceof Number
js> false instanceof Boolean

These are well-defined for instanceof, without throwing. Changing 
results to true would be backward incompatible.

ES4 had 'is' as a type-classifying operator:

It would be a mistake to define 'is' without defining the (unsound) type 
system it depends on. This is a challenge, but TypeScript and other 
close-to-ES6 languages have sallied forth. We need a detailed proposal.


More information about the es-discuss mailing list