[英]Javascript continue on forEach
不可能在forEach中使用“ continue”嗎? 以下給出錯誤。
var numbers = [4, 9, 16, 25];
function myFunction() {
numbers.forEach(function(val){
if(index==2){
continue;
}
alert('val: '+val);
});
}
是否還有其他可繼續使用的工作?
不可能在forEach中使用“ continue”嗎?
是。
是否還有其他可繼續使用的工作?
使用return
可以立即退出功能。
var numbers = [4, 9, 16, 25];
function myFunction() {
numbers.forEach(function(val){
if(index!=2)
alert('val: '+val);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.