Hi coders,
I’m learning Javascript and I stuck with this doubt in comparison:
What’s different between == and === ?
Thanks!!!
When you use ===
you are doing a strict comparison between the two values, ==
Instead enforce type conversion
So you can have
3 == '3' //true
3 === '3' // false
0 == false // true
0 === false // false
1 == true // true
1 === true // false
2 Likes
dont worry now. just go ahead. you will be familiar with this. i had also same issue at beginning
== double equal sign means you are comparing only the value of variables but using the === triple equal sign it checks the data type and value and compare it.
Therefore if I have to compare two values it is better to triple = rather than double =