-1
工作(foreach循环之后的任何概念)有什么我缺少有关forEach循环 这给出了一个错误为什么forEach循环是不是休息
VM847:5 Uncaught SyntaxError: Illegal break statement at Array.forEach() at :2:9
,这是工作的罚款,正常的循环。
var myArray = [{name:'John'}, {name:'Doe'}, {name:'Mice'}]
myArray.forEach(function(item, i){
if(item.name == 'Doe'){
console.log(i);
break;
}
});
'Array.prototype.forEach'是一种方法;不是循环语句。 – deceze
哦,我错过了forEach是一个函数,我们必须使用返回这个。 –