JS
See the Pen thecodelog.com - JS Booleans 1 by Deano (@deangilewicz) on CodePen.
Do not confuse the primitive boolean values true and false with the true and false values of the Boolean object as they are not the same thing.
When a method needs to be invoked on a primitive boolean value or a property lookup needs to occur JavaScript will automatically box (wrap) a primitive boolean with a Boolean object.
See the Pen thecodelog.com - JS Booleans 2 by Deano (@deangilewicz) on CodePen.
When the Boolean object is used (new Boolean()) the value passed as the first parameter is converted to a boolean value, if necessary.
If the value is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (“”), the Boolean object has an initial value of false. Also if the DOM object document.all is passed as a parameter, the Boolean object has an initial value of false.
All other values, including any object or the string “false”, creates an object with an initial value of true.
See the Pen thecodelog.com - JS Booleans 3 by Deano (@deangilewicz) on CodePen.
Boolean primitive values are useful when used in conditional logic but beware, do not use a Boolean object in place of a Boolean primitive.
See the Pen thecodelog.com - JS Booleans 4 by Deano (@deangilewicz) on CodePen.