= = Comparison of the rules in JS: tend to digitize (comparisons between different data types, excluding obj and obj)
= = between obj and obj compares only the address values stored in the stack
= = Operator parsing ①
First, the data types in JavaScript are divided into two groups:
1.String, Number, Boolean, and object (available)
2.Undefined and Null (none)
The comparison between 3.1 and 2 is false
The comparison between 4.Undefined and Null is True
5. Nan is not equal to Nan
Null and undefined had to say the story (the original intention of the designer)
If you're going to assign a variable to the value of the object type, but it's not assigned yet,
Then you can use NULL to indicate the state at this point (one of the evidences is that typeof null results in ' object ')
Conversely, if you're going to assign a variable to a value of the original type, but it's not yet assigned,
Then you can use undefined to represent the state at this time.
= = Operator parsing ②
parseint (value)
Parsefloat (value)
Conversion situation
String-as long as the highest bit is a number, it is converted to a numeric value; otherwise converted to Nan
Other->nan
Number ()
Conversion situation
is to remove the whitespace characters on either side of the string, and then remove the quotes on both sides to see if it can form a valid number.
If so, the result is this number; otherwise, the result is Nan.
Of course there are exceptions, such as the result of converting a blank string to a number is 0.
Boolean:true==>1
False==>0
Null==>0
Undefined==>nan
Object==>nan
= = Operator parsing ③
As can be seen from this example, the rules of the ToString () and valueof () methods of the built-in objects need to be remembered in addition to the two classifications in mind to grasp the rules of the = = operation.
Includes object, Array, Date, Number, String, Boolean, and so on
= = Operator parsing ④
undefined = = NULL, the result is true. And the result of comparing them to all other values is false.
String = = Boolean, which requires two operands to be converted to number at the same time.
String/boolean = = number, need String/boolean to number.
Object = = Primitive, requires object to Primitive (specifically through the valueof and ToString methods).
(Date tostring valueof)
JS basic knowledge = = operator