Strawman proposal: new `is` operator
impinball at gmail.com
Tue Aug 26 06:00:24 PDT 2014
I stand corrected on the creation aspect.
On Aug 25, 2014 9:56 PM, "Brendan Eich" <brendan at mozilla.org> wrote:
> Isiah Meadows wrote:
>> Cc the list...
>> On Aug 25, 2014 6:06 PM, "Isiah Meadows" <impinball at gmail.com <mailto:
>> impinball at gmail.com>> 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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss