javascript find index of key in object code example
Example 1: find index of object in array javascript
a = [
{prop1:"abc",prop2:"qwe"},
{prop1:"bnmb",prop2:"yutu"},
{prop1:"zxvz",prop2:"qwrq"}];
index = a.findIndex(x => x.prop2 ==="yutu");
console.log(index);
Example 2: indexOf by object key
var index = peoples.findIndex(p => p.attr1 == "john")
Example 3: js find index of object by value of property and return it's key
const index = Data.findIndex(item => item.name === 'John');