News for hackers. Stuff that matters.
Re:Silly Javascript by tlrobinson on Saturday July 25, 2009 @04:13PM (#723616)
Yeah I don't know why the author expected any reasonable behavior from using a string as an array index.

However, the same behavior is true of plain Objects.

Re:Silly Javascript by s3graham on Saturday July 25, 2009 @05:09PM (#723682)
I used [] because I hoped it would correctly handle number indices. But, I originally used {}. The auto-stringification of the keys was my complaint.
Re:Silly Javascript by axod on Saturday July 25, 2009 @05:16PM (#723688)
All keys are strings :/

What you're complaining about is similar to complaining that

"hello " + 3 + " world" == "hello " + "3" + " world"

Re:Silly Javascript by invisible on Sunday July 26, 2009 @01:36AM (#724094)
When assigning a String with a numeric value I think JavaScript treats it as a numeric for an Array and a String for regular Objects. This doesn't really change the difference, just that an Array should hold numerical index values (vs an Object key, but they CAN hold regular keys since they are an Object). A bit confusing I guess...