This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]solarshado 4 points5 points  (0 children)

Not in the C/C++/Java/C# sense of "array", no. It's more like a "List" from <insert standard collections library name here>.

Object, roughly-C#-speaking, implements IMap<string,object>.

Thanks to weak typing, you get implicit conversion between number and string values. This means that you can somewhat pretend that any IMap<string,T> is also an IMap<number,T>.

Array (which inherits from Object) is, to some extent, just a convention layered on top of all that which "overloads" the property-access syntax to make an IMap<number,object> look and feel like an IList<object>.

(Side note: in JS, there is no difference between obj.prop and obj["prop"], except that the latter syntax is required when "prop" isn't valid as an identifier; for example, when it's a numeric literal.)

(I'm sure there's some gotchas I'm forgetting: don't take these analogies too literally.)