1. for in 既可以遍历数组,也可以遍历对象;得到的结果是数组下标或对象属性名
for (let x in arr){
console.log(x)
}
2. for of只可以遍历数组,遍历对象会报错;得到的结果是数组的值
for (let x of arr){
console.log(x)
}
3. forEach跟for of类似 ,只可以遍历数组,不能遍历对象;得到结果也是数组的值
arr.forEach(x=>{
console.log(x)
})
arr.forEach(function(x){
console.log(x)
})