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

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