Find index in array of objects

后端 未结 4 2127
梦如初夏
梦如初夏 2021-01-18 15:54

I would like to find index in array. Positions in array are objects, and I want to filter on their properties. I know which keys I want to filter and their values. Problem i

4条回答
  •  隐瞒了意图╮
    2021-01-18 16:19

    Using Lo-Dash in place of underscore you can do it pretty easily with _.findIndex().

    var index = _.findIndex(array, { userid: '7', chid: 'default' })
    

提交回复
热议问题