forEach. How to break?


/ Published in: JavaScript
Save to your folder(s)

Array.prototype.forEach
You can't break forEach. So use "some" or "every".
Array.prototype.some
some is pretty much the same as forEach but it break when the callback returns true.
Array.prototype.every
every is almost identical to some except it's expecting false to break the loop.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.