1.= = equality operator
1.1 If the operands have the same type, the equivalence is judged, and true (equal) is returned if the values of the two numbers are equal, otherwise false (unequal)
1.2 If the two operand types are different, then the following rules are in order:
-
- Null is equal to undefined
- One is a number, the other is a string, then the string is converted to a number, and the comparison
- One of them is true, first converted to 1 (false translates to 0) in comparison
- If one value is an object and the other is a number or a string, the object is converted to the original value (via the ToString () or valueof () method)
- In other cases, it returns false directly.
2.= = = equals operator
2.1 If the operand type is different, it is not worth judging and returns false directly
2.2 If the operands are of the same type, the following rules are true:
-
- Are numbers, they are equal if the values are the same (exceptions:nan is not equal to itself ), otherwise it is not equivalent
- are strings, if the values of the strings are equal, otherwise they are not equivalent
- Are Boolean, and their values are true/false, equivalent, otherwise not equal
- If the two operands refer to the same object, the two are identical, otherwise they are not equivalent
- Equivalent if two operands are null/undefined, otherwise not equal
JavaScript = = = and = = =