Hey you programmer, okay? Let’s learn something new!
Because in most languages we don’t have these two comparators, just one that compares the equality
So let’s go to the definition of each one:
== (comparing values): The == compares only if the result is equal on both sides;
See some examples:
Note that even if we compare a string that represents the same int value, 1 == ‘1’, we have true
Because the == only checks the values
And also if we compare 1 == true, it also checks for true, because the 1 in the programming represents true too.
=== (compares identical values): An identical value can be defined as type and equal value
So see some examples:
Remembering that it is always safer to use ===, == can generate some unexpected failures
Precisely for being a little more liberal in relation to ===
There are two comparison operators, but with the == we only compare the equality of values
In ===, the identical operator, we compare the type and value to see if they are equal.