The difference between = and = in JavaScript (interview question) and javascript interview
= Used for general comparison, = used for strict comparison;
= The data type can be converted during comparison, === strict comparison, as long as the type does not match, flase is returned.
Example:
"1" = true; // true
Different types, "=" will first convert the type, convert true to 1, that is, "1" = 1;
At this time, the type is still different, continue type conversion, convert "1" to 1, that is, 1 = 1;
At this time, "=" both the left and right types are numeric, and the comparison is successful!
If the comparison is: "1" = true, the left side is the boolean type, the right side is the boolean type, the left side is different, and the result is false;
If the comparison is: "1" = 1, the left side is the numeric type, the right side is the int numeric type, the left side is different, and the result is false;
If the comparison is: 1 = 1, the left side is the int numeric type, the right side is the int numeric type, the left side is the same type, the value size is the same, and the result is true;
If the comparison is: 1 = 2, the left side is the int numeric type, the right side is the int numeric type, the left side is the same type, but the value size is different, the result is false;
In short, "=" only requires equal values; "=" requires equal values and types