Boolean type in JavaScipt
09 Sep 2014Boolean is a primitive data type, but you can create a boolean object using Boolean
constructor function by newing it:
// Case 1: using New operator
var a = new Boolean(false);
var result = a && true;
console.log(result); // true
console.log(a); // Boolean {[[PrimitiveValue]]: false}
// Case 2: Using Casting operator
var b = Boolean(false);
var result = b && true;
console.log(result); // false
console.log(b); // false