How do I use the includes method in lodash to check if an object is in the collection?

前端 未结 3 1234
一整个雨季
一整个雨季 2020-12-23 20:03

lodash lets me check for membership of basic data types with includes:

_.includes([1, 2, 3], 2)
> true

But the following do

3条回答
  •  爱一瞬间的悲伤
    2020-12-23 20:48

    You could use find to solve your problem

    https://lodash.com/docs/#find

    const data = [{"a": 1}, {"b": 2}]
    const item = {"b": 2}
    
    
    find(data, item)
    // > true
    
    

提交回复
热议问题