Javascript Array first(predicate)

Description

Javascript Array first(predicate)


Array.prototype.first = function (predicate) {
 for (var i=0; i<this.length; i++) {
  if (predicate(this[i])) {
   return this[i];
  }//ww w . j  a v  a2s . co  m
 }
 return undefined;
};

Javascript Array first(predicate)

Array.prototype.first = function (predicate) {
    for (var i = 0; i < this.length; ++i) {
        if (predicate(this[i]))
            return this[i];
    }/*from w w  w.  j  a  v  a  2  s. c  o  m*/
};



PreviousNext

Related