- Regular equals:
- Strict equals:
The difference between double equals (
==) and triple equals (
- Regular equals only compare values and ignore value type
- Strict equals compare both values and value types.
// returns true 5 == "5" // returns false 5 === "5"
In the two examples above, the value on the left is a numeric value type, the one the right is a string value type (specified by the quotes
They both have the value five but one is a numeric value the other is a string value. Strict equals
=== only evaluates to true if both the value and the value type is the same.
So both of these examples evaluate/return true because their value type on either side of the strict equals is the same:
// returns true 5 === 5 // returns true "5" === "5"