Array is equal not array:
[] == ![]; // -> true
Explanation:
The abstract equality operator converts both sides to numbers to compare them, and both sides become the number 0 for different reasons.
Arrays are truthy, so on the right, the opposite of a truthy value is false, which is then coerced to 0.
On the left, however, an empty array is coerced to a number without becoming a Boolean first, and empty arrays are coerced to 0, despite being truthy.
Here is how this expression simplifies:
+[] == +![];
0 == +false;
0 == 0;
true;
Follow @msabir for more such contents
Your thoughts!!!