ES6 Some vs Every

I learned a neat trick today. You can't break a javascript forEach loop but you can break a some and an every but there are specific rules.

`some` will only break when a value equivalent to true is returned`every` will only break when a vlue equivalent to false is returned

The reason is because these fuctions are accomplishing similar but different tasks. They each return an overall synonpsys of what happened durind each iteration.

For example:`some` will return `true` if SOME of the iterations return true.`every` will return `true` if EVERY of the iteractions returns true.

This explains why sometime they run full length and sometimes they don't. Dpeneds on the needs!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <pre>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.

More information about formatting options

CAPTCHA
Complete this form and then pat yourself on the back.