= = Equality equivalent, when the value types on both sides are different, the type conversion should be performed before comparison .
= = = Identity identity, do not do type conversion, different types of certain range .
The following are respectively explained:
first say = = =, this is relatively simple. The following rules are used to determine if two values are equal to = = =:
1. If the type is different, [unequal]
2, if two are numeric, and is the same value, then [equal]; Exception) is, if at least one of them is Nan, then [unequal]. (Determine if a value is Nan and can only be judged by isNaN ())
3. If two are strings, the characters are the same for each position, then [equal]; otherwise [unequal].
4, if the two values are true, or both are false, then [equal].
5. If all two values refer to the same object or function, then [equal]; otherwise [unequal].
6, if two values are null, or both are undefined, then [equal].
say = =, according to the following rules:
1, if two value types are the same, do = = = comparison.
2. If two value types are different, they may be equal. Type conversions are then compared according to the following rules:
A, if one is null and one is undefined, then [equal].
B, if one is a string, one is a numeric value, the string is converted to a numeric value and then compared .
C, if any value is true, convert it to 1 and then compare it to 0 if either value is false.
D, if one is an object and the other is a numeric or string, convert the object to the value of the underlying type and then compare it. The object is converted to the underlying type, using its ToString or ValueOf method. JS Core built-in class, will try to valueof before ToString, the exception is that date,date is using the ToString conversion. Non-JS Core object, another said (more trouble, I do not understand)
E, any other combination, are [unequal].
Example:
"1" = = True
Type, true will first be converted to a value of 1, now become "1" = = 1, and then the "1" into 1, compared to 1 = 1, equal.