for...in : For In « Statement « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » Statement » For In 
3.3.1.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>
3.3.For In
3.3.1.for...in
3.3.2.Window Object Properties Array
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.