Easy learning with example program codes

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


Sign Up/ Sign In
Ask a Question

Copyright © 2018 CodesJava Protection Status SiteMap Reference: Java Wiki