I have an array of number objects, which can be selected only if the orderable quantity is greater than 0. I have a select all checkbox that is checked or unchecked accordingly with this function:self.allSelected = function () {  return self.shownNumbers().filter(function (number) {    return number.isSelected();  }).length === self.shownNumbers().filter(function (number) {    return number.orderableQty > 0;  }).length;}I can also iterate over the array and return the result:self.allSelected = function () {  var s = 0, o = 0;  for (var i = 0; i < self.shownNumbers().length; i += 1) {    if (self.shownNumbers()[i].isSelected()) s ++;    if (self.shownNumbers()[i].orderableQty > 0) o ++;  }  return s === o;}The second one seems more readable and probably is more efficient since it iterates the array only once. Is there a way to use a single filter, map or other Array.prototype built-in function in order to reduce the code and make it more readable or should I keep the single loop option?
Simplify 2 filters on the same array
javascript;array;knockout.js