fill map javascript code example

Example 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.

Example 2: array js fill

let filledArray = new Array(10).fill({'hello':'goodbye'});

Example 3: new map js

let utilisateurs = new Map()

utilisateurs.set('Mark Zuckerberg' ,{
    email: '[email protected]',
    poste: 'PDG',
})

utilisateurs.set ('bill Gates',{
    email: '[email protected]' ,
    poste : 'sauver le monde' ,

})
    
console.log(utilisateurs);

Tags:

Java Example