I would like to know why the expression given in the title
[] == ![]
is evaluated to true
.
You cannot compare arrays as strings. I get that. If
[] == []
will evaluate to false because the references are different. Though if we have the following statement.
var arr = [];
arr == arr // this evaluates to true simply because references are the same.
In order A == B to return true
either A and B have to be false
or true
.
A == !B in order to return true
A can be true
and B can be false
or vice versa but in this case, A and B are the same values so I don't get it.