DEV Community

Discussion on: Difference Between some() and every() in JavaScript

Collapse
 
indoor_keith profile image
Keith Charles

Great post! I feel like you kind of touched on it, but I wanted to make sure it was pointed out:

With some() the method will return true IMMEDIATELY upon the first item that passes the test. While with every(), the method will return false IMMEDIATELY upon the first item that fails the test.

Which means if the first item in an array of 5 passes the test we provide insome() then it would return true after only one iteration. Likewise if the first item in an array of 5 would not pass the test we provide to every() then it would return false after one iteration.

Collapse
 
aoussiadmehdi profile image
Mehdi Aoussiad

Thank you! That's a good point that I talked about.