What is the difference between the equality operators == and ===?
Last updated
Was this helpful?
Last updated
Was this helpful?
Triple equals (===
) checks for strict equality, which means both the type and value must be the same. Double equals (==
) on the other hand first performs type coercion so that both operands are of the same type and then applies strict comparison.
Whenever possible, use triple equals to test equality because loose equality ==
can have unintuitive results.
Type coercion means the values are converted into the same type.
Mention of falsy values and their comparison.