What is the output of the following code: console.log(5 == “5”);?
a) true
b) false
c) NaN
d) undefined
Answer:
a) true
Explanation:
In JavaScript, the double equals == performs type coercion, meaning it converts the operands to the same type before comparing. Here, "5" (a string) is converted to 5 (a number), so the comparison is true.
Example:
console.log(5 == "5"); // Output: true
console.log(5 === "5"); // Output: false (strict equality without type coercion)