Differences between two operators
I am not clear about the exact differences between == and ===.Please do tell me the difference between them
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin MoreRank #1,419 · 1.2K reputationPosted Jan 18, 2012, 7:24 PM EST
its simple == checks only value whereas === checks valuse as well as Datatype
for e.g:-
1=="1" // is true
but
1==="1" //is false.
Thanks,
Pravin.
Sam HobbsRank #107 · 20.5K reputationPosted Jan 18, 2012, 10:29 PM EST
Vinitha TRank #8,005 · 230 reputationPosted Nov 8, 2021, 7:16 AM EST
Double Equals (==) - It checks with only value of operands. It is type converting conversion, it will convert the operands into same type and then it will compare the values.
Triple Equals (===) - It checks with value of operands and its datatype. It is Strict conversion, it wont perform any conversion when the operands are of different data types.
var a = 1;
var b = 1;
var c = "1";
console.log ( a == b ) ; // return true
console.log ( a === b ) ; // return true
console.log ( a == c ) ; // return true
console.log ( a === c ) ; // return false