JavaScript Tutorial/Statement/For In

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

The 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 loop looks like the following:

for (variable in object) {

Window Object Properties Array

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