(First off, I've been reading questions and answers here for a long time but this is my first post.)
I've found solutions that involve writing your own function for it, but I have to believe there's a built-in way to do this.
I'm working in JavaScript and have an array of custom objects, each of which look like this:
{ 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" }
I want to find a built-in way to find the array index of one of the objects given the value of one of its properties (for this example, if I gave it "prop2" and "bar" it would return index 2). It would be nice to use .indexOf like you'd expect, but apparently with an array of custom objects, it doesn't work that way.
I've found code for a function of my own that works fine, but in my stubbornness I'm convinced there's just got to be a built-in way to do it. I'm doing a ton of stuff in jQuery in this project, so that's absolutely an option as well. Any suggestions?