第一种:for(...in...)循环输出数组下标
var arr = ["a","b","c","d"]; //in:循环输出数组下标 for(let i in arr){ console.log(i); //0,1,2,3
}
第二种:for(...of...)循环输出数组的值
var arr = ["a","b","c","d"]; //of:循环输出数组的值 for(let i of arr){ console.log(i); //a,b,c,d }
第三种:for(......)循环输出数组的下标
var arr = ["a","b","c","d"]; //of:循环输出数组的值 for(let i=0;i<arr.length;i++){ console.log(i); //0,1,2,3 }