Open yongzeng opened 3 years ago
for循环 最原始
for (var index = 0; index < myArray.length; index++) { }
forEach 无法跳出循环 ES5
myArray.forEach(item=>{})
for in 对象的循环
for (let i in arr) {} i是键名,键名会转化成字符串。会乱序
for of 数组的循环,替代forEach ES6
for (let i of arr) {} i是键值 键名需要是数字(Uncaught TypeError: object is not iterable)
for循环 最原始
forEach 无法跳出循环 ES5
for in 对象的循环
for of 数组的循环,替代forEach ES6