for - in


Added in ES 2009.
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) {
   write(propertyVal);
   write(myobject[propertyVal]);
}

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



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