Differences between “==” and “===”
== and === Both are known as conditional equal operators. == (double equal) check the only value if the value is the same then return true else return false. On the other hand === (triple equal) check both value and data type if the value and data type are the same then return true else return false. It also can use as conditional not equal like !== .
var num = 30;
var num2 = "30";
if(num == num2){
console.log("both are same.");
}
output: both are same.
var num = 30;
var num2 = "30";
if(num === num2){
console.log("both are same.");
}
else if(num !== num2){
console.log("both are not the same.");
}
output: both are not the same.
Top comments (0)