Javascript - Looping with for...in
📖 Read the lesson
Code Life
By Pierre Marsaa
Looping Over the Keys
Arrays have
for
...of
to visit every value. Objects have
for
...
in
, which visits every
key
:
↗️
Loading editor...
↶
▶️ Run
↷
At each turn,
key
holds the name of a property, as a string:
"hp"
, then
"attack"
, then
"speed"
.
Loading editor...
Verify