You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
"arrays are just like regular objects" - That's interesting. Arrays, other than a few methods decorating them, are objects, and objects are...? Especially if an associative array is really just "cast" into an object magically. Are associative arrays still arrays in this sense? (I apologize in advance if my use of cast is incorrect.)Jared Farrish– Jared Farrish2011年02月19日 02:59:26 +00:00Commented Feb 19, 2011 at 2:59
-
@Jared In JavaScript, all objects are associative arrays.Šime Vidas– Šime Vidas2011年02月19日 03:04:40 +00:00Commented Feb 19, 2011 at 3:04
-
@Šime Vidas - So why have an array object? I'm just wondering, is it to expose the .length property? They seem to be so similar.Jared Farrish– Jared Farrish2011年02月19日 03:06:31 +00:00Commented Feb 19, 2011 at 3:06
-
1@Jared Use arrays when the member names would be sequential integers. Use objects when the member names are arbitrary strings or names.Šime Vidas– Šime Vidas2011年02月19日 03:11:18 +00:00Commented Feb 19, 2011 at 3:11
-
1@Jared 1. JavaScript does not convert arrays into objects. Arrays can contain non-indexed properties just like objects. In fact, arrays can do everything that regular objects can do (and a few things more). 2. In the realm of JavaScript, there exist only objects and primitive values. Only those two things. And objects have the characteristics of associative arrays. 3. BTW, I found a good definition of an object in JavaScript: An object is a collection of properties.Šime Vidas– Šime Vidas2011年02月19日 04:03:37 +00:00Commented Feb 19, 2011 at 4:03
lang-js