首页 > 代码库 > for...in 循环

for...in 循环

for...in 循环主要用于数组,也可用于对象。

for (var index in myArray) {    document.write(myArray[index]);}
var person = {    firstname : "Bill",    lastname : "Gates",    age : 56,}for (var index in person) {    document.write(person[index]);}