476 B
476 B
title, shortTitle, tags, author, cover, firstSeen
| title | shortTitle | tags | author | cover | firstSeen |
|---|---|---|---|---|---|
| Convert object to Map | Object to Map | object | chalarangelo | blog_images/succulent-2.jpg | 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}