📜  反应数组查找索引 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:11.993000             🧑  作者: Mango

代码示例1
//The findIndex() method returns the index of the first element 
//in the array that satisfies the provided testing function.
//Otherwise, it returns -1, indicating that no element passed the test.
const array1 = [5, 12, 8, 130, 44];

const isLargeNumber = (element) => element > 13;

console.log(array1.findIndex(isLargeNumber));
// expected output: 3