Behavior of Array(n).join(s)

Patrick Mulder mulder.patrick at gmail.com
Mon Jul 16 13:39:39 PDT 2012


Hello,

I am rather new to ES and this group, but I am surprised by this behavior:

When I do:

Array(4)
>>> [undefined, undefined, undefined, undefined]

And when I do:
>>> Array(4).join(" * ")
" * * * "

In other languages, I would not be able to join undefined objects.
Also, if it would be, I am surprised that I get only 3 x * whereas
above, I have 4 undefined. Anyone has some pointers, what I am
missing?

Thanks,
Patrick


More information about the es-discuss mailing list