If you do:
let arr = new Array(5); arr.fill([]);
This will make an array of 5 identical arrays where editing one will update all which is rarely what anyone wants. To achieve an array of different arrays use:
let arr = Array.from(new Array(5), () => [])
Leave a Reply