javascript for in loop tutorial

The for in loop is used to iterate the properties of an object.


for(property in object){
 //Block of statements 

JavaScript for in loop example:

var person = {Fname:"Mahesh", Lname:"Kumawat", Age:29};
var perproperty;
for (perproperty in person) {
document.write(perproperty + ": " + 
person[perproperty ] + "<br/>")  


Fname: Mahesh
Lname: Kumawat
Age: 29


Comments are closed.