Javascript Array filter(iterator)

Description

Javascript Array filter(iterator)


Array.prototype.filter = function(iterator) {
  var results = [];
  for (var i = 0, len = this.length; i < len; i++) {
    if (iterator(this[i], i)) {
      results.push(this[i]);//from w  ww  .j  a v a  2  s. c  o m
    }
  }
  
  return results;
};



PreviousNext

Related