Array.includes() to find object in array

前端 未结 6 969
名媛妹妹
名媛妹妹 2020-12-01 15:43

I\'m attempting to find an object in an array using Array.prototype.includes. Is this possible? I realize there is a difference between shallow and deep compari

6条回答
  •  遥遥无期
    2020-12-01 16:36

    you can use find to returns the value of the this element

    const array = [{a: 'b'}];
    array.includes(array.find(el=>el.a==='b'));
    

提交回复
热议问题