JavaScript
/Beginner
== vs ===
Definition
Double equals `==` (Loose Equality) compares two values after attempting to implicitly coerce them to the same type. Triple equals `===` (Strict Equality) compares both value AND type without doing any conversion.
Explain Like I'm New
Loose equality `==` is like a bartender who accepts a hand-drawn picture of an ID as proof of age. Strict equality `===` checks both the ID and scans it to make sure it's legally valid.
Real World Example
Always using `===` in React and modern JavaScript to prevent bizarre bugs where `0 == false` returns `true`.
Common Use Cases
- •Comparing variables
- •Linting rules (ESLint enforces `===`)
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- Why should you almost always use `===` instead of `==`?
intermediate
- Is there ever a good reason to use `==`?
advanced
- What is `Object.is()` and how does it differ from `===`?