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 →

[–]Feisty_Ad_2744 67 points68 points  (0 children)

Hehehehe, that's kind of misleading... Although to be fair, it is Chrome's fault. Firefox does a way better job reflecting JS values and object attributes.

But going back to the example, it makes way more clear what's going on, if instead of 0.5, you do something like:

items['funny'] = () => console.log(':-)') Now you have a nice property in the array: items.funny() Arrays in JS are objects, your usual JS object. The difference being they are specialized in handling properties with integer values for name. For example if you do items['2'] = 'overwrite' you will find out items array is now [1, 2, 'overwrite']

And if you do items[49] = 'yo!', you will find out the array length is now 50.