Find the index (findIndex) of an element (matching the requirements) in the object array

Find the index of an element in the object array that matches the requirement

let objectArr = [{
    name:'fur',
    age:18,
    time:1522801451
},{
    name:'furs',
    age:18,
    time:1222222
},{
    name:'furfur-jiang',
    age:18,
    time:333333
}]

let index = objectArr.findIndex(v=>v.name==='fur')
console.log(index) //0
Published 128 original articles · 52 praises · 20,000+ views

Guess you like

Origin blog.csdn.net/weixin_44523860/article/details/105335492