<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../js/jquery-3.2.1.min.js"></script>
<script>
var a=[11,22,33];
//index,為數組當前遍歷的數組的下標,elements為當前遍歷到的數組元素
$.each(a,function (index,elements) {
console.log(elements);
})
//輸出的a 為數組的下標
for(var aa in a){
console.log(a[aa]);
}
//obj對象
var obj={"name":"zhangsan","age":29}
//key為遍歷到當前對象的key,value為當前key對應的值
$.each(obj,function (key,value) {
console.log(key+":"+value);
})
//輸出的index 值為該對象的key值
for(var index in obj){
console.log(key+":"+obj[index]);
}
</script>
</head>
<body>
</body>
</html>