instanceof Operator

Eugen.Konkov at aldec.com Eugen.Konkov at aldec.com
Sun Oct 21 10:08:23 PDT 2007


Does instanceof operator check 'constructor' property in [proto] chain?

----- Original Message ----- 
From: "liorean" <liorean at gmail.com>
To: <es4-discuss at mozilla.org>
Sent: Sunday, October 21, 2007 8:03 PM
Subject: Re: instanceof Operator


> On 21/10/2007, Eugen.Konkov at aldec.com <Eugen.Konkov at aldec.com> wrote:
>> var a;
>> a= {};
>> a instanceof Object //true
>> a= [];
>> a instanceof Array //true
>> a='asdf';
>> a instanceof String //false
>> a= 7;
>> a instanceof Number //false
>>
>> Why?
> 
> Because those are primitives of type double and string respectively.
> They are not instances of any of the compound types Object, String or
> Number.
> 
> Something silly that JavaScript inherited from Java that the world
> would be much better off without, but as I understand it won't be
> corrected because of real world compatibility problems.
> -- 
> David "liorean" Andersson
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss



More information about the Es4-discuss mailing list