501 B
501 B
title, type, shortTitle, language, tags, author, cover, dateModified
| title | type | shortTitle | language | tags | author | cover | dateModified | |
|---|---|---|---|---|---|---|---|---|
| Convert object to Map | snippet | Object to Map | javascript |
|
chalarangelo | yellow-shoes | 2022-06-16T05:00:00-04:00 |
Converts an object to a Map.
- Use
Object.entries()to convert the object to an array of key-value pairs. - Use the
Mapconstructor to convert the array to aMap.
const objectToMap = obj => new Map(Object.entries(obj));
objectToMap({a: 1, b: 2}); // Map {'a' => 1, 'b' => 2}