es6 array object index string code example
Example 1: using index of on array of objects
arr = [{x: "a", y: 1}, {x: "something", y: 2}]
arr.findIndex(obj => obj.x === "a" && obj.y === 1);
Example 2: javascript findindex
const array1 = [5, 12, 8, 130, 44];
const search = element => element > 13;
console.log(array1.findIndex(search));
// expected output: 3
const array2 = [
{ id: 1, dev: false },
{ id: 2, dev: false },
{ id: 3, dev: true }
];
const search = obj => obj.dev === true;
console.log(array2.findIndex(search));
// expected output: 2