Why [] == [] is false in JavaScript?

前端 未结 6 1732
时光说笑
时光说笑 2020-12-03 17:32

I am working on a part of the code where I have an array which looks like [[data]]. The data is rendered on the server side through the Django temp

6条回答
  •  無奈伤痛
    2020-12-03 18:33

    Because [] creates a new array, so you are comparing one array object with another array object.

    It's not the contents of the arrays that is compared, the object references are compared. They are not equal because it's not the same object instance.

提交回复
热议问题