for...in : For In : Statement JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Statement » For In »

 

for...in











The for...in loop accesses to all the enumerated properties of a JavaScript object.

The statement(s) in the loop are executed for each property of an object until every property has been accessed.

Any parts of an object that are not enumerated are not accessed by this looping structure.

The format of the for...in loop looks like the following:








for (variable in object) {
      statement;
    }














<HTML>
<FORM NAME="aForm">
<INPUT TYPE="button" NAME="Big_Button" VALUE="Big Button" onClick="alert('The Big Button was pressed!')";>
</FORM>
<SCRIPT LANGUAGE='JavaScript'>
<!--
var aProperty;
for (aProperty in document.aForm.Big_Button) {
      document.write(aProperty,"<BR>");
}
//-->
</SCRIPT>
</HTML>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Statement
» For In