JSFiddle - React, Tailwind, and code Playground
JavaScript
var arr=[{ prop1: "1", prop2: "blah", prop3: "news", prop4: "2", prop5: "1" },
{ prop1: "2", prop2: "foo", prop3: "news", prop4: "2", prop5: "1" },
{ prop1: "3", prop2: "bar", prop3: "news", prop4: "2", prop5: "1" },
{ prop1: "4", prop2: "hello", prop3: "news", prop4: "2", prop5: "1" }];
Array.prototype.indexOfAssociative=function(property,value){
for(var i=0;i<this.length;i++){
if(this[i][property]==value){
return i;
}
}
return -1;
};
alert(arr.indexOfAssociative("prop2","bar"));