In javascript, [] === [] and [] == [] both returns false [duplicate]

江枫思渺然 提交于 2019-12-02 13:40:06

问题


why is that? I assumed it's some implicit type conversion at first, but [] == [] is also false.


回答1:


Arrays in javascript are Objects. Objects are compared by identity. So no two objects created by different literals (or by other means) are going to be equal (either strictly (===) or loosely (==)).



来源:https://stackoverflow.com/questions/34102957/in-javascript-and-both-returns-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!