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