for - in

Available in ES 2009.
This is for looping over iterables.
Iterators exist on maps, arrays and sets.

Iterating an Array

This should not be used to iterate over an Array where the index order is important.

Iterating an Object

This traverses all enumerable properties of an object
Iterates over the property keys of an object
This cannot iterate through a collection

var myobject = { 
   name: "Steve"
   age: 20
for (var propertyVal in myobject) {

var people = ["steve","john","people"]; 
for (i in people) {

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext