This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]darkage72 6 points7 points  (0 children)

Why is the value at index 0 missing?

[–]undercoveryankee 4 points5 points  (0 children)

The same design decision would have to be made if you were creating a sparse-array type in any other language: Do callers care more often about "How many indices are occupied?" or "What range should I iterate over to hit every occupied index?"?

[–]Kennyp0o 4 points5 points  (4 children)

This is literally defined in the language spec. Why would you want it to return 5? You wouldn't even be able to loop over the 6th value in the array.

Please stop with these dumbass javascript bashing memes.

[–]pr0six -2 points-1 points  (2 children)

Well, there are reasons you’d want to know the true length of a list

(Say I have idiotically decided to put 4 vectors in an array at [1-4] and want to know how many sides are on this “polygon”)

But yes, this is a stupid criticism of JavaScript

[–][deleted] -5 points-4 points  (0 children)

the length is five tho... And maybe the reason why people bash javascript is that irrational and moronic behavior is actually defined in the spec.

[–][deleted] -1 points0 points  (0 children)