Re:Silly Javascript
by mustpax on Saturday July 25, 2009 @03:47PM
(#723590)
First of all, I would strongly recommend you read Doug Crockford’s, JavaScript: the Good Parts. JavaScript has a lot of quirks and rough edges, but please do not try to use a language in a professional capacity without learning it first. To be fair, JavaScript pretends to be Java just enough to invite all this ill-advised behavior.
To answer the question fully: JavaScript arrays are really just plain objects. All objects in JavaScript are simply associative arrays, and all associative arrays are string indexed. So, subscripting always causes a string conversion. The Array class provides some convenience methods with .push() .pop() to gloss over this fact, but arrays are really no different than other objects.
Re:Silly Javascript
by axod on Saturday July 25, 2009 @05:04PM
(#723669)
I'd recommend "Javascript: The definitive guide" O'Reily far more. "The good parts" isn't really a full language spec. It's an interesting read, but not as useful IMHO
To answer the question fully: JavaScript arrays are really just plain objects. All objects in JavaScript are simply associative arrays, and all associative arrays are string indexed. So, subscripting always causes a string conversion. The Array class provides some convenience methods with .push() .pop() to gloss over this fact, but arrays are really no different than other objects.