What will the console.log([] == false) statement output?

What will the console.log([] == false) statement output?

a) true
b) false
c) undefined
d) NaN

Answer:

a) true

Explanation:

When comparing an empty array [] with false using the loose equality operator (==), JavaScript converts the array to a boolean and compares it with false, resulting in true.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top