Nodejs String Filter filter(func)

Here you can find the source of filter(func)

Method Source Code

String.prototype.filter = function(func) {
  str = this.split("");
  var ans = [];//from   w w  w  . j  a v  a  2s .  c o  m
  str.forEach(function(x) {
    if (func(x)) {
      ans.push(x);
    };
  });
  return ans;
};

Related

  1. filter(f)
    String.prototype.filter = function(f) {
      return this.split("").filter(f).join("");
    };