JS隨機(jī)色塊和遍歷數(shù)組題,for in和for of區(qū)別個(gè)人理解注釋翻譯版【詩書畫唱】




<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
var personShuZu=[
{'bianhao':007,'name':'詩書畫唱1','age':20},
{'bianhao':666,'name':'詩書畫唱2','age':21},
{'bianhao':233,'name':'詩書畫唱3','age':22},
];
for(var i of personShuZu){
for(var j in i){
document . write(i[j]+" ");
//i[j]這里為i['bianhao']等
//打印屬性(如'bianhao'等):
//for? ?of :遍歷數(shù)組的具體內(nèi)容或值
//for? in:遍歷數(shù)組的屬性(如'bianhao'等)
//document . write(j);
}
document . write("<br>");
}
</script>
</head>
<body>
</body>
</html>


標(biāo)簽: