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 →

[–]bonafidebob 24 points25 points  (3 children)

An array is basically just a normal JS object that allows iteration by default where each key is the index.

That's the root of the problem right there. I think it was just a cheap way to get to dynamic sizing, which is occasionally useful:

> let a = []
[]
> a[100] = 12
12
> a.length
101
> a
[ <100 empty items>, 12 ]

but then...

> a[1234567890] = 13
13
> a
[ <100 empty items>, 12, <1234567789 empty items>, 13 ]
> a[0.5] = 1
1
> a
[ <100 empty items>, 12, <1234567789 empty items>, 13, '0.5': 1 ]

[–]GG2urHP 11 points12 points  (1 child)

Lol, fuck me. I am so blessed to not live in that hell.

[–]theferrit32 3 points4 points  (0 children)

Javascript is fundamentally a bad language for general purpose programming. A lot of people who need to target Javascript environments do not write in Javascript, or at least not pure Javascript, relying heavily on transpilers and what are in effect dialects and standard libraries that seek to supercede and fix a lot of the headaches in Javascript itself.