There is no standardized function filterfor Javascript arrays, this is just an extension of the standard. (There is an ES5 specification published just a month after posting this answer.) The MDC man page gives you a compatibility pattern for those implementations that don't support it ...
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp*/)
{
var len = this.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = new Array();
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
{
var val = this[i];
if (fun.call(thisp, val, i, this))
res.push(val);
}
}
return res;
};
}
source
share