Differences between “==” and “===”

mdyasinmiah

Md Yasin Miah

Posted on December 28, 2021

Differences between “==” and “===”

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.
Enter fullscreen mode Exit fullscreen mode
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.
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
mdyasinmiah
Md Yasin Miah

Posted on December 28, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related