this is because == in JS forces conversion and if one type can be converted to another the return value is true and here because [] cant be changed or compared with bool it is false
where as if([]) checks for null and undefined values and because [] is neither null or undefined it is returning true
check this
Which equals operator (== vs ===) should be used in JavaScript comparisons?