# Ch2 程式控制結構
# **1.for-in loop**
Besides "for" loop, JavaScript offers another special loop called "for-in" loop.
In a "for-in" loop, the counting variable is a string rather than a number variable. The string represents the particular attribute of the given variable. For instance the following code shows off all the attributes of the object **document**:
```
<script>
for (prop in document):
document.write("<br>document."+prop+"="+document[prop]);
</script>
```
There are a whole lot of attributes of the object **document**, say, "charset" and "domain".The result is as below:

Needless to say, we can construct an object with multiple attributes, and use "for-in" loop to go through all the attributes. Like in:
```
<script>
student = new Object();
student.name = "Timmy";
student.age = "25";
student.phone = "0123456789";
for(prop in student){
document.write("<br>student."+prop+"="+student[prop]);
}
</script>
```