Prepare repository for merge

This commit is contained in:
Angelos Chalaris
2023-05-01 22:35:56 +03:00
parent fc4e61e6fa
commit b3ad01863a
578 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,22 @@
---
title: Convert object to Map
type: snippet
shortTitle: Object to Map
tags: [object]
author: chalarangelo
cover: succulent-2
dateModified: 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 `Map` constructor to convert the array to a `Map`.
```js
const objectToMap = obj => new Map(Object.entries(obj));
```
```js
objectToMap({a: 1, b: 2}); // Map {'a' => 1, 'b' => 2}
```