๐for-in
loop over "keys"
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).
can be used with for-in / for-of loop.
can't be used with a classic for-loop.
๐ no const for classic "for"โ
โญ๏ธ ๆณจๆ๏ผ for...in
, for...of
ๆ "(...)
" ๆฌ่โ๏ธ
for (let key in object) {} // loop over "keys"
for (let value of iterable) {} // loop over "values"
// ^ ^
๐ Property flags and descriptors - โflags-awareโ clone
Last updated
Was this helpful?