What is the difference between = = (equal) and = = = (all equal) in Javascript?
Let’s look at two examples first:
var n='100' ;
if(n==100)
{
alert('equal to');
}
else
alert('not equal to');
}
The result is "equal to";
When judging whether strings are the same,
var n=false;
if(n=='false')
alert('equal to');
}
else
alert('not equal to');
}
The result is "not equal to".
Reason: === When judging whether two values are the same, it will first judge whether the data type is consistent. If the data type is consistent, it will continue to judge whether the content is the same. == When judging, the data type will be ignored and the judgment will be made directly. The content switch uses full equal judgment
In js, undefined and null are equal if == is used, and unequal if === is used.