What is the difference between == and === in JavaScript?

What is the difference between == and === in JavaScript?

a) == performs type coercion, while === checks both type and value
b) === performs type coercion, while == does not
c) Both perform type coercion
d) There is no difference

Answer:

a) == performs type coercion, while === checks both type and value

Explanation:

The == operator in JavaScript checks for equality after performing type coercion, meaning it converts operands to the same type before comparing them. The === operator, on the other hand, checks for strict equality, meaning it compares both type and value without type conversion.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

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

Scroll to Top