Combining typeof and instanceof
Andrea Giammarchi
andrea.giammarchi at gmail.com
Sun Feb 3 15:09:59 PST 2013
you should link "Have you met Empty?" entry there:
http://webreflection.blogspot.com/2013/01/have-you-met-empty.html
It explains why typeof null is object, and provides more insights about the
Empty constructor and the root of JS inheritance.
Said that, the difference between is_type, is_a (is_instance), and
responds_to(BehaviorObject) from Ruby, is kinda important. Back to good old
cross frame problem when an Array.prototype could be polluted in frame-x
but not on top, isInstance(arrayFromFrame, Array) will fail there and this
is both expected behavior, and correct, IMHO.
Any attempt to clarify type and instances will result in more confusion,
same confusion has TypeScript between val:string and val:String, either
there is a rule about checking the class name or its symbol with an
operator or something will be ambiguous anyhow.
My 2 cents
On Sun, Feb 3, 2013 at 1:14 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
> It has always bothered me that one had to distinguish primitives and
> objects if one wanted to categorize values in JavaScript. The following is
> a proposal for changing that:
>
> http://www.2ality.com/2013/02/isinstance.html
>
> Comments and suggestions welcome.
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130203/1a358cc3/attachment.html>
More information about the es-discuss
mailing list