Created
May 14, 2019 05:09
-
-
Save NiallJoeMaher/41b23c7cdc1b708c03a16e9a783b9693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//With Object.fromEntries, you can convert from Map to Object: | |
const testMap = new Map([ ['hello', 'world'], ['lorem', 42] ]); | |
const result1 = Object.fromEntries(testMap); | |
console.log(result1); // { hello: "world", lorem: 42 } | |
//With Object.fromEntries, you can convert from Array to Object: | |
const testArray = [ ['first', 0], ['second', 1], ['third', 2] ]; | |
const result2 = Object.fromEntries(testArray); | |
console.log(result2); // { first: 0, second: 1, third: 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment