What is the difference between == and === in JavaScript?
By FrontendPro Editorial Team Updated 8/14/2026
Answer
== is the abstract equality operator while === is the strict equality operator. == performs type coercion before comparing, following the Abstract Equality Comparison algorithm defined in the ECMAScript specification. === does not perform coercion and returns false whenever the operand types differ. === is generally preferred in application code because it eliminates a class of bugs caused by unexpected coercion. The most common exception is x == null, which checks for both null and undefined in a single comparison.
| Operator | == | === |
|---|---|---|
| Name | Loose (abstract) equality operator | Strict equality operator |
| Type coercion | Yes - per the Abstract Equality Comparison algorithm | No |
| Comparison behavior | Types may be coerced before the value comparison | Types are compared first |
<br>Don't confuse
=with==and===.=is the assignment operator - it sets a variable's value (x = 5) and does not compare anything.
Read the detailed answer on GreatFrontEnd which allows progress tracking, contains more code samples, and useful resources.
