Notice that there are two different types of equality:
- Strict equality (
- Loose Equality (
1 === true // false 1 == true // true 0 === false // false 0 == false // true
0 as loosely equal. They are both represented by a
0 under the hood. Similarly,
1 are loosely equal and represented by a
1 under the hood.
Loose equality can cause confusion and accidents when coding. Try to stick to using
!== instead of
!= to determine if values are equal.