dorey / JavaScript-Equality-Table

Creative Commons Attribution Share Alike 4.0 International
1.24k stars 193 forks source link

Add Boolean object to the table #21

Open bananpermobil opened 9 years ago

bananpermobil commented 9 years ago

The Boolean object seem to get cast when using == but not when using ===.

ex. new Boolean(true) == true // -> true new Boolean(true) === true // -> false new Boolean(false) == false // -> true new Boolean(false) === false // -> false

Errorname commented 6 years ago

I think this can be explained with the following sentence from the Mozilla Javascript Reference Do not confuse the primitive Boolean values true and false with the true and false values of the Boolean object.

new Boolean(true) has a value of true but it's not the same value as the primitive boolean value true

Therefore, it's not strictly equal