0
Difference between == and === in JavaScript
*"I often see both == and === in JavaScript examples. What’s the actual difference between them? In which situations should I prefer one over the other? A clear example would really help!
1 Respuesta
0
== is equality, === is strict equality
== tries to convert the values in case they are of different types, while === does not try to convert.
Example:
"1" == 1 // true
"1" === 1 // false
Here's the documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality