4 ms·
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 no
by mustpax 17y ago
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.
- boucher 17y agoI'm not a huge fan of Doug's book, but I think this is an excellent read: https://developer.mozilla.org/en/A_re-introduction_to_JavaScript https://developer.mozilla.org/en/A_re-introduction_to_JavaSc...
- axod 17y agoI'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