> Boolean(new Boolean(false))
true
> Boolean([])
true
> Boolean({})
true
That is different from how objects are converted to number and string, where you can control the result by implementing the methods valueOf() and toString() [2].
As an example, let’s assume that new Boolean(false) coerces to false and use it in an expression:
new Boolean(false) && 1 && trueThat expression is evaluated in two steps:
new Boolean(false) && 1 → new Boolean(false)
new Boolean(false) && true → new Boolean(false)
For each step, you need to coerce new Boolean(false) to boolean in order to determine the result.
> {}.toString.call(document.all) // an object
'[object HTMLAllCollection]'
> Boolean(document.all) // falsy!
false
> typeof document.all // strange!
'undefined'