How can I Display a JavaScript ES6 Map Object to Console?

There is a more simpler solution you can try.

const mapObject = new Map();
mapObject.set(1, 'hello');

console.log([...mapObject.entries()]);
// [[1, "hello"]]

console.log([...mapObject.keys()]);
// [1]

console.log([...mapObject.values()]);
// ["hello"]

Leave a Comment