array-methodseasy
What is the difference between == and ===?
Answer
=== compares type and value with no conversion. == coerces the operands to a common type first, which produces surprises like '' == 0 and '1' == 1 being true. Use === by default. The one common exception is x == null, which is a concise way to test for null or undefined together.
Points an interviewer listens for
- === strict: no coercion
- == coerces, producing non-obvious truths
- Default to ===
- x == null is a deliberate, useful exception
Reported at
Similar questions have been reported by candidates at Deloitte, Desun Technology, Digiflux Technologies Private Limited, Easework AI, FactWise, Gaian Solutions India.
Now try answering it out loud
Interview practice mode times your spoken answer and checks it against the points above.
Practise this question