1. The forEach method jumps out of the loop ---- jumps out of the loop by throwing an exception and skips the current loop through return
var arr=[1,3,5,7,9];
var id = 5;
try{
arr.forEach(function(curItem,i){
if(curItem===1)return;
console.log(curItem);
if(curItem===id){
throw Error();
}
})
}catch(e){
console.log(e)
}
2. The for method jumps out of the loop -----break jumps out of the loop continue jumps out of the current loop
var arr=[1,3,5,7,9];
var id = 5;
for(var i=0;i<arr.length;i++){
if(arr[i]===1)continue;
console.log(arr[i])
if(arr[i]===id){
break;
}
}