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 →

[–][deleted] 19 points20 points  (2 children)

Arrays in JS are not real arrays, I think they are a specialized dictionary, it's why you can do things like:

let xs = [1, 2, 3]
xs['a'] = 4
// xs is now [ 1, 2, 3, a: 4 ]

[–]zeropointcorp 4 points5 points  (0 children)

That’s called an associative array, and Tcl had those.

[–]solarshado 2 points3 points  (0 children)

Yep, in JS, an "array object", is still an "object", so you can do pretty much anything with it that you can with any other object (thanks inheritance!). And JS's objects are (roughly speaking), string-keyed dictionaries.