๐for-in
loop over "keys"
Last updated
Was this helpful?
loop over "keys"
Last updated
Was this helpful?
Was this helpful?
JSโฉ syntax โฉ for loops โฉ for-in
iterates over all (own/inherited) enumerable string properties of an object (ignoring properties keyed by symbols).
for (const <key> in obj) {} // loop over "keys"
for (<variable> in obj) {}
// <variable> can be a let/const/var, or an "lvalue" (assignment target).
for-in (loop over keys)
for-of (loop over values)
for (let key in object) {} // loop over "keys"
for (let value of iterable) {} // loop over "values"
// ^ ^