Array.includes() to find object in array

前端 未结 6 980
名媛妹妹
名媛妹妹 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:23

    Its' because both of the objects are not the same. Both are stored at different place in memory and the equality operation results false.

    But if you search for the same object, then it will return true.

    Also, have a look at the below code, where you can understand that two identical objects also results false with the === operator.

    For two objects to return true in ===, they should be pointing to same memory location.

提交回复
热议问题