function printMap(value, key) {
console.log(`${key}, ${value}`);
}
const arr = [
{ id: 1, language: 'javascript' },
{ 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, javascript"
"2, node.js"
"3, typescript"
"4, php"
[[1, "javascript"], [2, "node.js"], [3, "typescript"], [4, "php"]]
*/