Array.prototype.filter = Array.prototype.filter || function(func) { var arr = this; var r = []; for (var i = 0; i < arr.length; i++) { if (func(arr[i])) { r.push(arr[i]); } } return r; }
var items = [ 1, 2, 3, 4, 5, 6]; items = items.filter(function (item) { return (item ===2 ); });