What is the core difference between == and === in JavaScript?
- A.
==compares by reference,===compares by value - B.There is no difference, they are just two ways to write the same operation
- C.
==compares with type coercion,===compares both value and type - D.
===is faster, so it always yields a different result than==
Answer: C
== coerces both operands to the same type before comparing (0 == "" → true), while === strictly compares both value and type with no coercion (0 === "" → false). Common practice is to prefer === to avoid surprising results.
References