3 ms·
>// now arr is [empty, empty, 2, '-4': -4] This isn't pseudo-code. It's what your browser will output as the value for arr What will seem weird and unexpected
by Aerroon 3y ago
>// now arr is [empty, empty, 2, '-4': -4]
This isn't pseudo-code. It's what your browser will output as the value for arr
What will seem weird and unexpected in this is that you're essentially dealing with dictionaries rather than arrays. They just have a length attribute bolted on that counts the highest key number as a length.
- graftak 3y agoHighest key number + 1
- deleted 3y ago[deleted]
- moritzwarhier 3y agoYes that's what it is and I still would agree with you that this one of the really interesting warts/quirks of JS. Sorry if my comment sounded antagonistic, wasn't intended that's why I was editing some of it before reading your reply.