1, for String,number and other basic types, = = and = = = There is a difference
1) Comparison of different types, = = Comparison of "converted to the same type of value" to see if "value" is equal, = = = If the type is different, the result is not equal to 2) the same type comparison, direct "value" comparison, the results of the same
2, for Array,object and other advanced types, = = and = = = There is no difference betweenMake a "pointer address" comparison
3, the basic type and the advanced type, = = and = = = There is a difference1) for = =, the advanced conversion to the underlying type, the "value" Comparison 2) because the type is different, = = = The result is False
Arithmetic rules for strict operators |
Equality operators The equality operator, when comparing data of the same type, Exactly the same as the strict equality operator. When comparing different types of data, The equality operator first converts the data into a type and then compares it with the strict equality operator |
(1) Different types of values If the two values are of different types, return false directly. |
(1) Value of the original type Data from the original type is converted to a numeric type and then compared. Both the string and the Boolean value are converted to numeric values. So there will be a second string output in the problem of the main question. |
(2) Primitive type values of the same class When comparing values (numeric, String, Boolean) of the original type of the same type, Returns True if the value is the same, false if the value is different. |
(2) Comparing objects to primitive type values objects, which are generalized objects, including numbers and functions, are compared to the values of the original type. The object is converted to a value of the original type and then compared. |
(3) Composite type values of the same class When comparing data from two composite types (objects, arrays, functions), Instead of comparing their values for equality, they are compared to whether they point to the same object. |
(3) Undefined and null Undefined and null when compared to other types of values, The results are false, and they compare to true when compared to each other. |
(4) undefined and null Undefined and null are strictly equal to themselves. null === null //trueundefined === undefined //true
|
(4) Disadvantages of the equality operator The type conversions that are hidden by the equality operator introduce some counterintuitive results. ‘‘==' 0 '//false0 == "//True0 == ' 0 ' //truefalse == ' false ' //falsefalse == Span class= "S1" > ' 0 ' //truefalse == undefined Span class= "C1" >//falsefalse == null //false< Span class= "KC" >null == undefined //true \t\r\n ' == 0 //true
This is why it is recommended that you try not to use equality operations |
Smile. Angle of rotation
qq:493177502
The difference between "js" = = = = = = =