W3C home > Mailing lists > Public > public-html@w3.org > July 2007

Re: HTMLCollection item() vs. namedItem() with [] syntax (detailed review of the DOM)

From: Cameron McCormack <cam@mcc.id.au>
Date: Mon, 9 Jul 2007 20:52:01 +1000
To: public-html <public-html@w3.org>
Message-ID: <20070709105201.GB16818@arc.mcc.id.au>

Maciej Stachowiak:
> This is why for ECMAScript arrays, 0, 0.0, .0 and "0" all work as  
> numeric subscripts for the built-in Array type, but "0.0" and ".0" do  
> not.
> 
> javascript:alert(["a"][0]) -> a
> javascript:alert(["a"]["0"]) -> a
> javascript:alert(["a"][0.0]) -> a
> javascript:alert(["a"]["0.0"]) -> undefined
> javascript:alert(["a"][.0]) -> a
> javascript:alert(["a"][".0"]) -> undefined
> 
> The model here is that numeric values get converted to string and then  
> string-compared with the appropriate string represetnation of an  
> integer, so it does not matter how they are spelled. But strings  
> undergo no conversion.

That’s a subtelty I missed, thanks…

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Monday, 9 July 2007 10:52:09 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:38:46 UTC