JavaScript Tutorial/Statement/For In — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:25, 26 мая 2010

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;
    }


Window Object Properties Array

<HTML>
<HEAD>
   <TITLE>Window Object Properties Array</TITLE>
</HEAD>
<BODY>
<SCRIPT>
for (var i in window) {
  document.write ("Window property(" + i +  "): " +
     window[i] + "<BR>");
}
</SCRIPT>
</BODY>
</HTML>