Javascript For In Loop Control

The Javascript for in statement iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed. In each iteration one property from object is assigned to variable and this loop continues till the end of the object.


<script type="text/javascript">
for (variable in object) 
  block to execute 

Javascript For In Loop Control Example

<!DOCTYPE html>
<head>  <!-- -->
<title>My first Javascript code</title>   
<body bgcolor="#bnde45">
<legend>Javascript For In Loop</legend>
var obj = {a:1, b:2, c:3}; 
for (var prop in obj) {
  document.write(prop + " = " + obj[prop]);