Javascript Array mapAndFindById(idKey, id, callback)
Array.prototype.mapAndFindById = function (idKey, id, callback) { return this.map((element, index) => { if (element[idKey] === id) { return callback(element, index); }//from ww w . jav a 2 s . c om return element; }); };