21, Feb 2023
== operator performs type coercion before making a comparison, while the
=== operator does not. This means that if you use
"5" == 5 will return
"5" to the number
5 before making the comparison. However,
"5" === 5 will return
false, because the operands are not of the same type.
It is generally recommended to use the
However, in some cases, using
== can be useful, for example when comparing values with different types but that you want to consider equal, like comparing
In summary, use
=== operator when you want a strict comparison without type coercion, and use
== when you want a comparison with type coercion.