mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-24 12:36:23 +00:00
597 B
597 B
date | id | title |
---|---|---|
2020-11-13 | 55435d35-26e1-460b-a683-ef346c9972a8 | Object.entries |
Description
Returns object properties as key / value pairs. Can be used with maps as well. It does the opposite of Object.fromEntries.
Syntax
console.log(Object.entries({ one: 1, two: 2 })); // [['one', 1], ['two', 2]]
Maps
let map = new Map(
Object.entries({
one: 1,
two: 2,
})
);
console.log(JSON.stringify([...map])); // [["one", 1], ["two", 2]]