Re: JavaScript typeof checking a Request value
Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
[color=blue]
> Please note that {} is an object which has no properties and no identity.[/color]
The syntax "{}" is a literal notation for an object. Its prototype
chain points to Object.prototyp e, so it has properties (toString,
constructor, etc.), just not any enumerable properties.
It has identity. That is why
var x={},y={}; alert(x==y);
gives false, while
var x={};alert(x==x );
gives true.
It is bordering to incorrect to say that "{}" is *an* object. It
*creates* an object, and is in fact equivalent to "new Object()". If
evaluated more than once, it crates more than one object.
var a=[];
for(var i=0;i<2;i++){
a[i]={};
}
alert(a[0]==a[1]);
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
[color=blue]
> Please note that {} is an object which has no properties and no identity.[/color]
The syntax "{}" is a literal notation for an object. Its prototype
chain points to Object.prototyp e, so it has properties (toString,
constructor, etc.), just not any enumerable properties.
It has identity. That is why
var x={},y={}; alert(x==y);
gives false, while
var x={};alert(x==x );
gives true.
It is bordering to incorrect to say that "{}" is *an* object. It
*creates* an object, and is in fact equivalent to "new Object()". If
evaluated more than once, it crates more than one object.
var a=[];
for(var i=0;i<2;i++){
a[i]={};
}
alert(a[0]==a[1]);
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Comment