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
mdn
docs
Description of Object.fromEntries() on MDN.