new Boolean(false)
returns an object which is not null. Non-null objects are always truthy.
As a result, !
of any non-null object will always be false.
To prove it to yourself, you can run this in your javascript console
(typeof new Boolean(false)) //"object"
Also, you can use the strict equality
operator to confirm that new Boolean(false)
isn't really false
:
new Boolean(false) === false // false
Incidentally, calling the Boolean
function as a function—without the new—actually does return a primitive
!Boolean(false) // true
(typeof Boolean(false)) //"boolean"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…