JavaScript · Objects

for…of Object.entries()

The clearest way to iterate own object properties with keys and values.

Syntax
for (const [k, v] of Object.entries(obj))

Example

Try it

More in this group

Computed property delete operator in operator Object.assign() Object.entries() Object.freeze() Object.fromEntries() Object.hasOwn()

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course