Equality in JavaScript is very convoluted, e.g. an array containing a single element of value "0" is considered == false, but an array containing a single element of value "1" is considered == true.
So it's really best to try to use === and !== where possible, only using == and != where absolutely necessary. Things are more predictable that way.
7
u/Jackrussell17 May 28 '19
Equality in JavaScript is very convoluted, e.g. an array containing a single element of value "0" is considered == false, but an array containing a single element of value "1" is considered == true.
So it's really best to try to use === and !== where possible, only using == and != where absolutely necessary. Things are more predictable that way.
See this table for a full rundown: https://dorey.github.io/JavaScript-Equality-Table/unified/