Interviews4 answers
What is the difference between == & === in javascript?
4 Answers
Salman BegPosted Sep 8, 2020, 6:26 AM EDT
In detail Example
0 == false // true0 === false // false, because they are of a different type1 == "1" // true, automatic type conversion for value only1 === "1" // false, because they are of a different typenull == undefined // truenull === undefined // false'0' == false // true'0' === false // false
Jay Krishna ReddyPosted Aug 22, 2020, 1:33 AM EDT
- ‘==’ : it does the necessary type conversions before doing the equality comparison.
Ex:
1 == ‘1’ => True
1 == 1 => True
1 == ‘5’ => False - ‘===’ : it will not do the type conversion hence if the two values are not of the same type, when compared, it will return false
Ex:
1 === ‘1’ => False
1 === 1 => True
1 === ‘5’ => False
Santhosh Kumar DevangaPosted Aug 21, 2020, 7:08 AM EDT
== ignores the datatype of variable and === does not it.
Example:
4 == "4" => true4 === "4" => false4 === 4 => true
Cristopher CoronadoPosted Aug 19, 2020, 3:48 PM EDT




