To create an array of x
elements in length where all elements are undefined to begin with, I use the Array(x)
function. If I enter this into the Chrome devtools console, it is displayed in a shorthand notation like this:
If I then use the spread operator (...
) to shallow-copy this array, the representation changes to a full array printout:
If I manually enter the array, the full printout is also used:
Why is this? What are the conditions for Chrome's undefined × x
shorthand to be used?
Edit
Using the new
keyword before creating the array of undefined
s does not make a difference to Chrome's representation: