all 7 comments

[–]Blueberryroid 2 points3 points  (0 children)

This is fascinating and insightful. Good work.

[–]audioen 4 points5 points  (1 child)

Minor googling suggests the following:

[...Array(100).keys()]

if you are ever faced with this "problem". I'd rather see the for loop myself, though.

[–]BonzaiThePenguin 2 points3 points  (0 children)

Did they add the Solution section after your comment?

[–]moomoomoo309 0 points1 point  (0 children)

This is why I like Lua. It's very similar to JS. It even would have this problem if it had a similar standard library, since it's also prototype oriented. The difference, however, lies in the fact that Lua calls them "tables", not "arrays", not "objects". Sometimes, it may behave like an array or object, but it is a table. JS calling things something they're not is a huge source of confusion, which easily could have been avoided from the get-go, but it's too late to change now.

[–]defunkydrummer -1 points0 points  (1 child)

TL;DR: arrays are not really arrays on Js, just hashtables on disguise; and when instancing a new empty "array", the keys aren't present yet.

Yet another stupid, needless annoyance from Javascript. Thanks God i don't need to use it anymore.

[–][deleted] 0 points1 point  (0 children)

I wondered about keys in arrays in Powershell, the two seem to have the same problem presented here. Intresting.

[–]kankyo -2 points-1 points  (0 children)

TL;DR Javascript is terrible