for ... in循环用于循环访问对象的属性。
这是语法-
for (variablename in object){ statement or block to execute }
尝试以下示例实现“ for-in”循环。打印网络浏览器的Navigator对象
<html> <body> <script> var aProperty; document.write("Navigator Object Properties<br /> "); for(aProperty in navigator) { document.write(aProperty); document.write("<br />"); } document.write ("从循环中退出!"); </script> </body> </html>