Boolean objects in conditionals

Peter Michaux petermichaux at gmail.com
Fri Nov 28 13:42:45 PST 2008


The following suggests (i.e. could be interpreted as) a false Boolean
object is a "truthy" value.

> (new Boolean(false)) ? "a" : "b"
"a"

The following suggests a false Boolean object is a "falsy" value

> ((new Boolean(false)) == true) ? "a" : "b"
"b"

I understand what is going on here but it seems like a bad state of affairs.

Does this need to be remedied? Can it be?

It would be useful to have an object that is effectively "false" in an
"if" conditional but which can also have properties like an object
can.

Peter


More information about the Es-discuss mailing list