_.some

Tests whether any of the elements in the array pass the test implemented by the provided function.

  1. // Underscore/Lodash
  2. function isLargerThanTen (element, index, array) {
  3. return element >= 10
  4. }
  5. var array = [10, 9, 8]
  6. var result = _.some(array, isLargerThanTen)
  7. console.log(result)
  8. // output: true
  9.  
  10. // Native
  11. function isLargerThanTen (element, index, array) {
  12. return element >= 10
  13. }
  14.  
  15. var array = [10, 9, 8]
  16. var result = array.some(isLargerThanTen)
  17. console.log(result)
  18. // output: true

Browser Support for Array.prototype.some()

ChromeEdgeFirefoxIEOperaSafari
1.5 ✔✔ 9.0