+ 3
what is difference identical(===) and equal to (==) operator in JavaScript?
please explain in detail what is difference identical(===) and equal to (==) operator in JavaScript. why identical (===) operator is also called as strictly equal to operator?
5 Réponses
+ 10
The 3 equals sign (===) mean "strict equality". Unlike double equals (==), the values must be equal in type too. For example:
1 == "1" // true
1 === "1" // false
0 == false // true
0 === false // false
false == "0" // true
false === "0" // true
null == undefined // true
null === undefined // false
I hope that helps. :)
+ 3
thank you Stellar Fox
+ 2
The == operator will compare for equality after doing any necessary type conversions.
The === operator will not do type conversion.
ex:
"1" == 1 // true
Here because of type conversion (the actual term is "implicit type coercion"), the values will be converted to the same type before being compared so "1" which is a string will be converted to the number 1.
Now that both are the same type, their values are compared and as they are the same, the result will be true.
"1" === 1 // false
However, there is no implicit type coercion when you use the strictly sign operator.
https://medium.freecodecamp.org/js-type-coercion-explained-27ba3d9a2839
+ 1
(==) means the left is equal to the right but (===) means the left is equal to the right and also in type.
0
Pls explain