why is that? I assumed it's some implicit type conversion at first, but [] == [] is also false.
Asked
Active
Viewed 588 times
1 Answers
4
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 (==
)).

Hunan Rostomyan
- 2,176
- 2
- 22
- 31
-
in javascript: `[] === []` equals new `Array() === new Array()` which means two instances of array. – Sagi Dec 05 '15 at 08:49
-
1@T.J.Crowder I've always felt a bit uneasy about those terms. Thanks for the heads up. – Hunan Rostomyan Dec 05 '15 at 08:50