Go to "next" iteration in javascript forEach loop -
this question has answer here:
- “continue” in cursor.foreach() 2 answers
how go next iteration of javascript array.foreach() loop?
for example:
var myarr = [1,2,3,4]; myarr.foreach(function(elem){ if (elem === 3) { // go "next" iteration. or "continue" next iteration... } console.log(elem); }); i'm surprised isn't question - search turning nothing, same suggested answers. mdn docs mention breaking out of loop entirely, not moving next iteration.
you can return if want skip current iteration.
since you're in function, if return before doing else, have skipped execution of code below return statement.
Comments
Post a Comment