Search code examples
javascriptcomparison-operators

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


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


Solution

  • 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 (==)).