Then I realized it was built by a few Java developers. If you check the documentation of Java Equality, Relational and Conditional Operators you soon find out why it was written like that.
In Java, there are only double equals operators (==). So there was my “aha” moment.
Double equality (==) operator
The == operator will start with checking the type of the value. If the type is not equal, it’s gonna check the value. If the value is equal it will return true, otherwise false. Like in this example:
How works == underwater
The type or value needs to equal to get a result of true, otherwise, it will be false.
Here is an example of how the double equality operator works underwater:
So only the value is checked. But the first value is a type number and the second is a string. So if you want to have the reliable code, the double equality operator does not what you would expect (except if you already knew this).
Triple equality (===) operator
The === starts with checking type equality, just like the == operator. If it is equal it will check the value equality, if not it will be false. If the type and value are equal, it will be true. Like this example:
How works === underwater
The type and value need to equal to get a result of true, otherwise, it will be false.
Here is an example of how the triple equality operator works underwater:
Using the triple equals operator will also make your code and checkings in it more reliable. Other developers can trust that what you expect is definitely true because you compare the value and type of the value.
Hopefully, this makes it all clear, if not please ask your questions in the comments, I’m happy to help you out!