i'm playing with nodejs and mongoose — trying to find specific comment in deep comments nesting with recursive func and foreach within.(我正在玩nodejs和mongoose - 尝试在深层注释中找到特定注释,并使用递归函数和foreach进行嵌套。)
Is there a way to stop nodejs forEach?(有没有办法阻止nodejs forEach?) As i understand every forEach iteration is a function and and i can't just do "break",only "return" but this won't stop foreach.(据我所知,每个forEach迭代都是一个函数而且我不能只做“休息”,只能“返回”,但这不会阻止foreach。)
function recurs(comment){
comment.comments.forEach(function(elem){
recurs(elem);
//if(...) break;
});
}
ask by kulebyashik translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…