Comparison operators are distinguished following simple logic, whether data type is being included or not.
Essentially if it is === or !==, then the comparison includes a type verification.
Example:
var numberVar = 1;
var stringVar = "1";
//compare if equal
var equals = numberVar == stringVar; //equals will be set to true
var stricterEquals = numberVar === stringVar; //stricterEquals will be set to false
//compare if different
var diff = numberVar != stringVar; //diff will be set to false
var stricterDiff = numberVar !== stringVar; //stricterDiff will be set to true
No comments:
Post a Comment
Please provide any feedback or post questions here...