Answers for "js array fill map"

1

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.
Posted by: Guest on May-31-2020
7

fill array with values javascript

let filledArray = new Array(10).fill({'hello':'goodbye'});
Posted by: Guest on February-18-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language