Converts an object to a Map
.
Object.entries
to convert the object to an array of key-value pairs.Map
constructor to convert the array to a Map
.const objectToMap = obj => new Map(Object.entries(obj));
objectToMap({a: 1, b: 2}); // Map {'a' => 1, 'b' => 2}
JavaScript, Object
Converts a Map
to an object.
JavaScript, Object
Deep maps an object's keys.
JavaScript, Object
Maps the keys of an object using the provided function, generating a new object.