Comparing Javascript with an empty array and boolean

As you can see in this javascript equality table , the transitivity of javascript equality is strange.

I understand most of the results of the table, but I have a question regarding the following comparison:

[] == true // false [] == false // true !![] == true // true !![] == false // false 

But also:

 if ([]) { // this code will run } if (!![]) { // and of course this too } 

Why? Is this another extremely bad part? Do you have a reasonable explanation?

+5
source share

Source: https://habr.com/ru/post/1210281/


All Articles