Javascript Array all(predicate)

Description

Javascript Array all(predicate)


/*My desicion*///from  w ww .  j  a  v a  2s .  co m

Array.prototype.all = function(predicate){
  for (var i = 0; i < this.length; i++){
    if (!predicate(this[i])) {
      return false
    }
  }
  return true
}

Javascript Array all(predicate)

Array.prototype.all = function (predicate) {
 return !this.any(function(x){ return !predicate(x); });
};



PreviousNext

Related