Sometimes, throughout your journey through Js codes you will see that more and more people use the triple equal “===” these comparators called “strict comparators” can be used since the implementation of ECMAScript 3.
The main difference between these comparators and the usual equality comparator is that with strict comparators the compared objects have to have the same type in addition to the same value, that is:
- Two Strings are strictly the same if they have the same length, the same characters in their corresponding positions, the same sequence of characters… etc.
- Two numbers are strictly equal if they have the same numerical value.
- NaN is not equal to anything, not even to itself.
- Positive zero and negative zero are equal to themselves.
- Two Boolean operators are strictly equal if both are true or both are false.
- Two objects are strictly the same if they both refer to the same Object.
- Null and Undefined are == but not ===.
0 == false // true
0 === false // false, are of different type
1 == “1” // true, automatic type conversion and value comparison
1 === “1” // false, are of different type
null == undefined // true
null === undefined // false
‘0’ == false // true
‘0’ === false // false
