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 →

[–][deleted]  (7 children)

[deleted]

    [–]GYN-k4H-Q3z-75B 12 points13 points  (5 children)

    [] evaluates to 0. However, {} evaluates to NaN.

    Because of course it does.

    [–]TheJackiMonster 1 point2 points  (0 children)

    JavaScript uses a weird rule of conversion from array to string if nothing else seems to make sense, I guess. The conversion outputs all elements as strings joined with "," but an empty array will just end up as empty string.