程序员人生 网站导航

JavaScript for/in循环的用法实例

栏目:jscript时间:2014-01-31 01:01:01

JavaScript for/in循环的用法实例,虽然For、IN大家用着不习惯,不过各有各的优势和个性,用好了一样是优秀的代码。

<html>
<head>
<title>for/in循环</title>
</head>
<body>
<center><h2>测试for/in循环</h2></center>
<hr>
<script language="JavaScript">
// 变量声明
var prop;
var objAddress = new Object();
objAddress.name = "陈会安";
objAddress.age = "33";
objAddress.phone = "02-22222222";
objAddress.email = "hueyan@ms2.hinet.net";
// 循环语句
for (prop in objAddress){
document.write("属性: " + prop + "=" + objAddress[prop] + "<br>");
}
// liehuo.net
</script>
</body>
</html

------分隔线----------------------------
------分隔线----------------------------

最新技术推荐