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)
Have a look to the join documentation.
What you're passing to the join function will be used as separator between the elements of the array. When you declare an array with Array(3)
, you're creating an array with three elements. The join method inserts your separator between those elements and so you will see only two "lorem".
Actually, what you see is: blank lorem blank lorem blank
. Where blank is the empty elements of the array.
Try to do the following:
var fruits = ["banana", "orange", "apple"]
fruits.join("lorem")
It will print
bananaloremorangeloremapple