Array.prototype.forEach = function (cb) { for (var i = 0; i < this.length; i++) { cb(this[i], i, this); } }; Array.prototype.map = function (cb) { var res = []; for (var i = 0; i < this.length; i++) { res[i] = cb(this[i], i, this); } return res; }; Array.prototype.filter = function (cb) { var res = []; for (var i = 0; i < this.length; i++) { if (cb(this[i], i, this)) res.push(this[i]); } return res; }; Array.prototype.find = function (cb) { for (var i = 0; i < this.length; i++) if (cb(this[i], i, this)) return this[i]; return -1; };