_.every

Tests whether all 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, 20, 30]
  6. var result = _.every(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, 20, 30]
  16. var result = array.every(isLargerThanTen)
  17. console.log(result)
  18. // output: true

Browser Support fpr Array.prototype.every()

ChromeEdgeFirefoxIEOperaSafari
1.5 ✔9.0 ✔