Inspired by this popular speech I wanted to figure out some issue related to creating arrays. Let\'s say I am creating new array with:
Array(3)
If you have an Array of 3 members, the .join
is the filler in between the members, so there should only be two join strings.
Therefore your second output is correct.
Your first output using .join()
, seems like a display bug or a misrepresentation of your testing code.
The default value for .join()
is a ","
, so this:
new Array(3).join();
should give you this:
",,"
The output that you show:
[, ,]
will more likely come from just typing new Array(3)
in the console
without the .join()
.