Before using JavaScript, you will occasionally encounter the use of = = and = = Two symbols to determine whether two variables are equal. But the difference between the two symbols has not been investigated. Today I met the symbol = = =, so I decided to check the difference between the two.
In JavaScript there are "= =" and "= =" Two comparison operators, then what is the difference between them?
First, for String,number and other basic types, = = and = = There is a difference
1 different types of comparisons, = = comparison "into the same type of value" to see whether the "value" is equal, = = = If the type is different, the result is unequal
2 the same type of comparison, directly to the "value" comparison, the results of the same
Second, for Array,object and other advanced types, = = and = = is no difference
When a variable is defined as Arrary and a variable is defined as type object, but its value is the same, the result of = = and = = is the same, because it is a "pointer address" comparison
Three, the base type and the advanced type, = = and = = There is a difference
1 for = =, the advanced conversion to the underlying type, for "value" comparison
2 because the type is different, = = = The result is False