+ 3

What is the difference between == and === ?

we == for comparing value then why === is used. when we == it only compares value not datatype so when we use === it will compare data type also ex:5 and '5' are different one int and another is string so it should wrong but it will you true in == becoz.. if you use === then it will you false

4th May 2017, 4:49 PM
chetan457
chetan457 - avatar
7 Réponses
+ 17
== compares only value but === compares both the value and type. 12 == "12" is true 12 === "12" is false since data types are different
4th May 2017, 4:52 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 5
in JavaScript: Semantic wise: == checks for equality, i.e. it will compare the value of two objects will return true if they are, else false if they aren't === checks for identity, i.e. it will compare the value and the type of two object. If both match, then it will return true, otherwise false. Performance wise: === is faster than == since it doesn't cast the type of both to be compared objects. Once it notice that two objects are of different type it returns false. Therefore === is faster than ==.
4th May 2017, 4:57 PM
Thanh Le
Thanh Le - avatar
+ 2
I can't see the tag
5th May 2017, 5:50 PM
xCalifier
xCalifier - avatar
+ 1
* the "===" operator doesn't exist in htlm, c++ and java
4th May 2017, 9:26 PM
Toky R.
Toky R. - avatar
+ 1
@toky Html is not a programming language, its a markup language.
4th May 2017, 11:05 PM
xCalifier
xCalifier - avatar
0
yep
4th May 2017, 4:54 PM
chetan457
chetan457 - avatar
0
@xCalifier, I know html isn't a programing language. I mentioned it because he taged it
5th May 2017, 4:40 AM
Toky R.
Toky R. - avatar