Skip to content

Commit aab98f5

Browse files
authored
convert an array of key-value into an object
1 parent 76efd6b commit aab98f5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# JavaScript-snippets
2-
> Click :star: if you like the project. Pull Request are highly appreciated. Follow us on [Facebook](https://www.facebook.com/snippetsJS)
2+
> Click :star: if you like the project. Pull Request are highly appreciated. Follow us on [Facebook](https://www.facebook.com/snippetsJS)
33
44
### Table of Contents
55
| No. | Questions |
@@ -44,7 +44,7 @@
4444
|38 | [How to change the value of an object which is inside an array](#How-to-change-the-value-of-an-object-which-is-inside-an-array)|
4545
|39 | [Numeric separators allow us to improve our code readability](#Numeric-separators-allow-us-to-improve-our-code-readability)|
4646
|40 | [pay attention when using every](#pay-attention-when-using-every)|
47-
47+
|41 | [How to convert an array of key-value tuples into an object](#How-to-convert-an-array-of-key-value-tuples-into-an-object)|
4848

4949

5050

@@ -880,6 +880,27 @@ console.log(result) //true
880880
881881
882882
883+
**[⬆ Back to Top](#table-of-contents)**
884+
### How to convert an array of key-value tuples into an object
885+
886+
887+
```javascript
883888
889+
const JSarr = [
890+
['name', 'JSsnippets'],
891+
['address', 'worldwide'],
892+
['year', '2018'],
893+
['followers', '15000']
894+
895+
];
896+
897+
const obj = Object.fromEntries(JSarr);
898+
//{
899+
// "name": "JSsnippets",
900+
// "address": "worldwide",
901+
// "year": "2018",
902+
// "followers": "15000"
903+
//}
904+
```
884905
885906

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy