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)
In console I am getting:
[undefined, undefined, undefined]
Which is pretty obvious. Let's say I am doing joining on that array:
Array(3).join()
As a response I am getting:
",,"
Which is pretty understandable as well, because these are three empty strings, separated by commas, I suppose. But when I am trying to do:
Array(3).join("lorem")
I am getting string with only two repeat of ”lorem”:
"loremlorem"
Why there are two, not three repeats of that word?
join(), why do you expect there to be 3lorems?join()method should do. Now it is all clear to me.