Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A false boolean object (as
opposed to a primitive value) created from the Boolean() constructor is an object, and objects
convert to true. Thus, when creating a
false boolean object via the Boolean() constructor, the value itself converts
to true. Below, I demonstrate how a
false boolean object is always
“truthy.”
<!DOCTYPE html><html lang="en"><body><script> var falseValue = new Boolean(false); console.log(falseValue); // we have a false boolean object, but objects are truthy if (falseValue) { // boolean objects, even false boolean objects, are truthy console.log('falseValue is truthy'); } </script></body></html>
If you need to convert a non-boolean value into a boolean, just use
the Boolean() constructor without the
new keyword and the value returned will
be a primitive value instead of a boolean object.