Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 21:58:35 +03:00
parent 1d189c709a
commit 61200d90c4
440 changed files with 0 additions and 0 deletions

21
snippets/map-to-object.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Convert Map to object
shortTitle: Map to object
tags: object
author: chalarangelo
cover: succulent-1
firstSeen: 2022-06-16T05:00:00-04:00
---
Converts a `Map` to an object.
- Use `Map.prototype.entries()` to convert the `Map` to an array of key-value pairs.
- Use `Object.fromEntries()` to convert the array to an object.
```js
const mapToObject = map => Object.fromEntries(map.entries());
```
```js
mapToObject(new Map([['a', 1], ['b', 2]])); // {a: 1, b: 2}
```