= = Equality equivalent, = = identity identity.
= =, when both sides of the value types are different, you have to do type conversion, and then compare.
= =, does not do the type conversion, the type difference must be unequal.
The following are described separately:
First say = = =, this is relatively simple. The following rule is used to determine whether two values are equal to = =:
1, if the type is different, [not equal]
2, if two are numeric, and is the same value, then [equal]; Exception is, if at least one of them is Nan, then [not equal]. (To determine whether a value is Nan and can only be judged by isNaN ())
3, if two are strings, each position characters are the same, then [equal]; otherwise [unequal].
4, if two values are true, or all false, then [equality].
5, if two values all refer to the same object or function, then [equal]; otherwise [unequal].
6, if two values are null, or are undefined, then [equality].
again = =, 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 and comparisons are made according to the following rules:
A, if one is null, one is undefined, then [equals].
B, if one is a string, and one is a numeric value, the string is converted to a numeric value and then compared.
C, if either value is true, convert it to 1 and compare it to 0 if any value is false.
D, if one is an object, and the other is a numeric value or a string, the object is converted to the underlying type for a comparison. object to the underlying type, using its ToString or ValueOf method. JS core built-in class, will try to valueof before ToString, the exception is date,date use of ToString conversion. Non-JS core objects, make said (more trouble, I do not understand)
E, any other combination, [not equal].
Example:
"1" = = True
Type, true will first be converted to a value of 1, now become "1" = 1, and then convert "1" to 1, compared to 1 = 1, equal.
= Assignment operator
= = equals
= = = Strictly equal To
Cases:
var a = 3;
var B = "3";
A==b returns True
Because the type of a,b is different.
= = = Used for strict comparative judgment
The above is a small set of JavaScript to introduce the three equals sign and two equal sign of the difference (= = = = =), hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!