r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

Show parent comments

19

u/ahartzog Mar 19 '19

TIL about array.every. Awesome tool, thanks!

11

u/Satoshi_Hodler Mar 19 '19

There's a small caveat that it always returns true on empty arrays, which might be not what you need.

27

u/Tysonzero Mar 19 '19

That's the mathematically correct thing to do, it's actually a pretty fundamental mathematical principle. Vacuous truth

1

u/third774 Mar 19 '19

Is there a similar term for .some() always returning false on empty arrays? I suppose it's still "vacuous", right? So maybe "Vacuous Falsity"?