Double equal operator or == is also known as the equality or abstract comparison operator. This operator transforms the operands having the same type before comparison. You can use the equality operator to check the identity of two operands even though they are not of a similar type. And this actually is one of the most important uses of equality operator – to check whether the two operands are the same or not by changing an expression from one data type to the other.
Double equal operator or == will always convert the variable values to the same type before it will perform a comparison. This is called type coercion.
You can use == to compare two variables, but in the process, you will ignore the data type of variables. (Type coercion)
If you decide to use ===, you will also compare two variables, but this operator will not ignore the data type – it will check the data types and then compare the two values. (Type conversion)
So the main message to take home is the following. The == will compare the equality of two operands, but it will ignore their type, therefore it will return true if the two operands are equal and false if the two operands are not equal. This operator will first check the equality only after doing the necessary conversions.
The === will check the equality of two operands with their types- === takes a type of variable into consideration, therefore the === will return true only if both values and data types are the same for both variables. However, if the two variable values are not of the same type the === will not perform any conversion.