Object.fromEntries()
converts key-value pairs (entries) into an object
fromEntries()
method is defined on Object
(not on the object literal)
GIVEN a list of entries (a key and a value) each WILL be converted into an object
WHERE an entry is an array with two elements
WHEN using arr.entries()
the array-index becomes the key and values stay values
WHERE an entry is a Map, and key and value map naturally
WHERE an entry is a Set, the values are used as keys too
WHERE an entry is an object, the properties 0
and 1
are key and value
Links
Description of Object.fromEntries() on MDN.
Related Katas
Global Object API
Object API
Object()
(as introduced in ES1)Object.is()
Object.fromEntries()
Object.fromEntries()
in depthObject.groupBy()
Object literal
Difficulty Level
INTERMEDIATE
First Published
28 July 2019
Stats
6 tests to solve