5 ms·
Why does every() return true for empty arrays?
- corentin88 3y agoWhile JS might be "unexpected" sometimes, I like very much that the reason behind this behavior is a mathematical concept.
- ajuc 3y agoThe alternative (breaking !every([], !f(x)) == some([], f(x))) is worse.
- dolni 3y agoI don't understand why this behavior is surprising to anybody. If you have a list of three things, the condition must be met for three things. Likewise for a list of two things, the condition must be met for two things. The pattern holds for one thing, and zero things.