JavaScript · Language basics

for…in

Iterates enumerable property names, including inherited ones. Use Object.keys for own keys only.

Syntax
for (const key in object) { … }

Example

Try it

More in this group

Arrow function Chained comparison Comma operator Default parameter destructuring for…of Function declaration if / else

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