Javascript Array indexOfByProp(obj, property)
Array.prototype.indexOfByProp = function(obj, property) { let result = -1; // console.log(this); this.forEach(function(currentObj, index) { if (currentObj[property] === obj[property]) { result = index;//from www .j a va 2 s.co m } }); return result; };