get index from array code example
Example 1: react array find index
const array1 = [5, 12, 8, 130, 44];
const isLargeNumber = (element) => element > 13;
console.log(array1.findIndex(isLargeNumber));
Example 2: how to find the index of a value in an array in javascript
var list = ["apple","banana","orange"]
var index_of_apple = list.indexOf("apple")
Example 3: javascript get index of object in array
const needle = 3;
const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }];
const index = haystack.findIndex(item => item.id === needle);
Example 4: js get index of item in array
array.indexOf("item");
Example 5: indefOf
const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];
console.log(beasts.indexOf('bison'));
Example 6: indexof javascript
arr.indexOf(searchElement[, fromIndex])