function printMap(value : any , key : any) {
console.log(`${key}, ${value}`);
}
const arr = [
{ id: 1, language: 'c++' },
{ id: 2, language: 'node.js' },
{ id: 3, language: 'typescript' },
{ id: 4, language: 'php' },
];
const mp = new Map(
arr.map(object => {
return [object.id, object.language];
}),
);
mp.forEach(printMap);
console.log(mp);
/*
run:
"1, c++"
"2, node.js"
"3, typescript"
"4, php"
Map (4) {1 => "c++", 2 => "node.js", 3 => "typescript", 4 => "php"}
*/