Javascript Array grep(rx)

Description

Javascript Array grep(rx)


Array.prototype.grep = function (rx) {
  var a = [], r = new RegExp(rx);
  for (var i = 0; i < this.length; i++) {
    if (r.test(this[i])) a.push(this[i]);
  }/*from  ww w .  j  a  v a  2s. co m*/
  return a;
};



PreviousNext

Related