Javascript Array copy(predicate)
Array.prototype.copy = function(predicate) { var newArray = new Array(); this.forEach(function(element) { if (predicate(element)) { newArray.push(element);/* w w w. ja v a2 s . c o m*/ } }); return newArray; };