What is the difference between == and === in JavaScript?
a)
==
performs type coercion, while ===
checks both type and valueb)
===
performs type coercion, while ==
does notc) Both perform type coercion
d) There is no difference
Answer:
a)
==
performs type coercion, while ===
checks both type and valueExplanation:
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.