I know with core Javascript we can do things like this:
for(i=1;i<10;i++){
if(i==5){
//break or continue
}
}
But why this is not correct ?
$.each(iteratorarray,function(i){ //iteratorarray - just an array
if(i==5){
//break or continue,will cause error here
}
});
This behavior is what is implemented by jQuery. This is what jQuery api document say "We can break
the $.each() loop at a particular iteration by making the callback function return false
. Returning non-false
is the same as a continue
statement in a for loop; it will skip immediately to the next iteration", You can read about it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With