Let me explain:
let count = new Array(4).fill([])
Here you create just 2 arrays actually. one is []
and second contains 4 links to []
.
In other words you are creating an array of 4 links to the single instance of array.
--
let count = Array.from(Array(4), () => new Array());
Here you create 5 different arrays. 4 different empty []
and array that contains 4 links, one link to each unique []
.
In other words here you create array filled with a different arrays