Because .fill()
takes the argument and, if it's an object, it copies the reference to that object into every index of the new array. Since in fact []
is an object, your new array ends up being filled with references to the same array.
From the docs:
If the first parameter is an object, it will copy its reference and fill the array with references to that object.