1、for(var i=0; i<10; i++):遍历数组
var arr = ['11', '22']; for(var i=0; i<arr.length;i++){ console.log(arr[i]); } //'11' '22'
2、for...in:遍历对象+遍历数组
var arr = { name: 'Anna', age: 20 }; for(var key in arr){ console.log(key); //name age console.log(arr[key]); //'Anna' 20 }
3、for...of:遍历数组
var arr = ['11', '22']; for(var key of arr){ console.log(key); //'11' '22' }