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!

Leave a comment

Your email address will not be published. Required fields are marked *