Js determined empty array

 Recently encountered such a situation when so Albert located

 

 

 The result here is an empty array, while the console output and the false, that is to say such a situation

if([]) // true
[]==true // fasle

As for why this is so, I understand that, first of all empty array ([]) is false, but if calls Boolean, while the array is an object, it will return true , and therefore if ([]) the result is true.

 

Guess you like

Origin www.cnblogs.com/kusaki/p/12469247.html