Here you can find the source of filter(f)
String.prototype.filter = function(f) { return this.split("").filter(f).join(""); };
String.prototype.filter = function(func) { str = this.split(""); var ans = []; str.forEach(function(x) { if (func(x)) { ans.push(x); }; }); return ans; ...