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

+23-2
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)