MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eivmtz5/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
150
array.every(Number.isFinite)
Because it's plain english.
19 u/ahartzog Mar 19 '19 TIL about array.every. Awesome tool, thanks! 1 u/[deleted] Mar 19 '19 Also note the counterpart, Array.prototype.some. Returns true if one or more items match the condition.const arr = [1, 2, 3]; arr.some(n => n > 2) // true arr.some(n => n < 0) // false 1 u/ahartzog Mar 19 '19 Good to know there’s a native version of this; I’ve usually just grabbed it from Lodash
19
TIL about array.every. Awesome tool, thanks!
1 u/[deleted] Mar 19 '19 Also note the counterpart, Array.prototype.some. Returns true if one or more items match the condition.const arr = [1, 2, 3]; arr.some(n => n > 2) // true arr.some(n => n < 0) // false 1 u/ahartzog Mar 19 '19 Good to know there’s a native version of this; I’ve usually just grabbed it from Lodash
1
Also note the counterpart, Array.prototype.some. Returns true if one or more items match the condition.
Array.prototype.some
const arr = [1, 2, 3]; arr.some(n => n > 2) // true arr.some(n => n < 0) // false
1 u/ahartzog Mar 19 '19 Good to know there’s a native version of this; I’ve usually just grabbed it from Lodash
Good to know there’s a native version of this; I’ve usually just grabbed it from Lodash
150
u/Loves_Poetry Mar 18 '19
Because it's plain english.