how to fill empty array in rect js code example
Example 1: javascript fill array
const fill = new Array(5).fill(0)
console.log(fill) // [ 0,0,0,0,0]
Example 2: js array fill map
let filledArray = new Array(10)
.fill(null)
.map(()=> ({'hello':'goodbye'}))
// In this approach, we are creating an array with ten empty slots,
// then filling those slots with the null value,
// then creating a new array with unique objects.
// Now when we change an object in the array,
// we are only changing a specific object, not a reference to an object.