Before knowing the difference between "==" vs "===" in JavaScript lets know about what are the == and != operator.
== vs !=
so the double equals (==) operator use to check if two values are equals and not equals (!=) if the two values are not equal
and its return type is always boolean like true **or **false.
In == and != both operater do type conversion before comparing the elements For e.g : - 2 == '2' so in this == operate do type conversion implicitly like before comparing it will do implicitly type coercion like 2 == Number('2') and then it will show output as *true **so this is what happens when we compares using == operater before showing output it add string '2' value in number fucntion and convert into number 2 and the comparing's we get the output as a true which 2 == 2
**for E.g *
let xxx = 2;
let xxxx = '2';
console.log(xxx == xxxx);// true
Now Check with === operater is also called as strictly equality operator thats means it will not do any type conversion internally
For E.g:
let x = 1;
let y = '1'
console.log(x===y)// output will false
Top comments (0)