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

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. Animation
30. MS JScript
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
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
w___w_w._j___a_va___2___s.___c_o___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.