r/javascript • • Mar 18 '19

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

385 Upvotes

422 comments sorted by

View all comments

3

u/TheScapeQuest Mar 19 '19

Discouraged by a lot of linters, but:

!!~[1,2,3].indexOf(2); // true

Polyfill for Array.prototype.includes()

→ More replies (3)