Javascript For in Loop

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

Syntax:

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

JavaScript for in loop example:

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