Javascript analogue of Ruby's "any?"
[true, true].every(Boolean)
true
[true, true, false].every(Boolean)
false
[true, true, null].every(Boolean)
false
[true, true, ""].every(Boolean)
false
[].every(Boolean)
true
Written by Alexey Astafyev
Related protips
2 Responses
Hey, man, look here http://underscorejs.org/#any
;) Also a good thing, right?
over 1 year ago
·
Yep. Underscore.js rules!
But this pro tip is just for plain JavaScript.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#