The strict equality operator ===
is used to compare two values. It requires both the value and the type of the operands to be the same to return true
. If either the value or the type is different, the result will be false
.
In the above code, numberValue
is of the type number with the value 9 and stringValue
is of the type string with the value 9. Since their types differ, the strict equality operator returns false
.
The sentenceOne
is of the type string with the value The name is Oliver. and sentenceTwo
is of the type string with the value The name is Oliver. and as their type and value matches, the strict equality operator returns true
.
Boolean Comparisons
Here, valueOne
is of the type boolean with the value true
and valueTwo
is of the type string with the value true
. The types are different, so the result is false
.
Comparing Objects
In the above code, objOne
and objTwo
have the same structure but are stored in different memory locations, so they are not strictly equal.