dorey / JavaScript-Equality-Table

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Boolean object to the table

bananpermobil opened this issue · comments

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

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