Re:Silly Javascript
by axod on Saturday July 25, 2009 @05:03PM
(#723667)
Read a book on javascript.
"Javascript: The definitive guide" by O'Reily is the best.
This is not a quirk, Arrays are just objects with a special property 'length' which is set to the highest key that can be converted to an integer, plus one, and the array functions. All keys are however, strings, as with all objects.
It's much easier when you understand that arrays in javascript don't exist as a separate data type. They are, as I say, just objects with a couple of convenience methods+length property.
"Javascript: The definitive guide" by O'Reily is the best.
This is not a quirk, Arrays are just objects with a special property 'length' which is set to the highest key that can be converted to an integer, plus one, and the array functions. All keys are however, strings, as with all objects.
For example,
It's much easier when you understand that arrays in javascript don't exist as a separate data type. They are, as I say, just objects with a couple of convenience methods+length property.