This article briefly describes the differences between (equal to) and (equal to) in Javascript. If you need it, refer to it.
What is the difference between = (equal to) and = (all equal to) in Javascript?
Let's take a look at two examples:
Var n = '20140901 ';
If (n = 100)
{
Alert ('equals ');
}
Else
{
Alert ('not equal ');
}
The result is "equal ";
When determining whether a string is the same,
Var n = false;
If (n = 'false ')
{
Alert ('equals ');
}
Else
{
Alert ('not equal ');
}
The result is "not equal ".
Cause: = when determining whether the two values are the same, the system first checks whether the data types are consistent. If the data types are the same, the system continues to judge whether the content is the same. =, the data type is ignored, and the switch directly determines that the content is equal to the total value.
In js, the use of undefined and null with = is equivalent, and the use of = is not equal.