Iterating entries with Object.entries

suggest change

The proposed Object.entries() method returns an array of key/value pairs for the given object. It does not return an iterator like Array.prototype.entries(), but the Array returned by Object.entries() can be iterated regardless.

const obj = {
    one: 1,
    two: 2,
    three: 3
};

Object.entries(obj);

Results in:

[
    ["one", 1],
    ["two", 2],
    ["three", 3]
]

It is an useful way of iterating over the key/value pairs of an object:

for (const [key, value] of Object.entries(obj)) {
    console.log(key); // "one", "two" and "three"
    console.log(value); // 1, 2 and 3
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Objects:
* Syntax
* Iterating entries with Object.entries

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
24 Loops
27 Date
29 Scope
30 AJAX
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
102 Tilde