📌  相关文章
📜  在数组中查找对象的索引 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:23.350000             🧑  作者: Mango

代码示例5
//     findIndex(callback fn)  

//    .... return index (when condition meets)
//  .... return -1 (if condition not meets)

const array = [5, 12, 8, 130, 44];

/// it returns the index of number which satisfy the condition true
const index = array.findIndex((item)=> item>10);   //1

/// now we can check what element at that index...
console.log(array[index]); // array[1]