What is the output of the following code: console.log([] == false);?
a)
true
b)
false
c)
undefined
d)
NaN
Answer:
a)
true
Explanation:
In JavaScript, an empty array []
is loosely equal (==
) to false
due to type coercion. When using ==
, both operands are converted to the same type before comparison, resulting in true
for [] == false
.