How to Convert an Object to a Map in JavaScript
In this lesson, we will see how to convert an object to a map in JavaScript, sometimes we want to convert a given object to a map in JavaScript so how can we do that?
The Object.entries() method
To do that we can use the Object.entries() method that returns a Map from a given object.
const myObject = {name: 'john', age: 30, city: 'London'};
const myMap = new Map(Object.entries(myObject));
myMap.get('name');
//john