Javascript Array filterArrayLength(callback)
var names = ["Lars", "Jan", "Peter", "Bo", "Frederik"]; //Filter Prototype Array.prototype.filterArrayLength = function(callback) { var newArray = []; for(var i = 0; i < this.length; i++) { if(callback(this[i])) newArray.push(this[i]);//from w w w . j a va 2 s.c o m } return newArray; }; var filterArray = names.filterArrayLength(function(name){ return name.length <= 3; }); console.log("Filter Prototype: " + filterArray);