xxxxxxxxxx
// Executes a callback function on each entry in your Map.
const user = new Map([
['First Name', 'Divine'],
['Last Name', 'Orji'],
['Age', 24],
[false, 'Dance'],
]);
user.forEach((value) => {
console.log(value);
});
/*
Divine
Orji
Dance
Gary
*/
xxxxxxxxxx
// Creating a map using Map object
let mp=new Map()
// Adding values to the map
mp.set("a",1);
mp.set("b",2);
mp.set("c",3);
// Logging map object to console
mp.forEach((values,keys)=>{
console.log({ values }, { keys });
})