DEV Community 👩‍💻👨‍💻

Cover image for Differences between “==” and “===”
Md Yasin Miah
Md Yasin Miah

Posted on

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

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.