forEach 数组实例的遍历方法 const arr=['red', 'green', 'blue']; arr.forEach(function(element, index) { console.log(element);// red green blue console.log(index);// 0 1 2 }); forEach这种写法的问题是,无法中途跳出forEach循环,break命令或return命令都不能奏效. for...in JavaScript原有的循环,只能获得对象…