for-in 语句
for 语句是严格的迭代语句,用于枚举对象的属性。
它的语法如下:
for
(propertyin
expression) statement
例子:
for (sProp in window) { alert(sProp); }
这里,for-in 语句用于显示 window 对象的所有属性。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
for(sProp in window){
document.write(sProp+"<br/>");
}
</script>
<body>
</body>
</html>