to true except the following: Strings: "", '', Numbers: 0, -0, NaN, Special: null, undefined, Boolean: false. The Boolean function can be used to explicitly convert to a primitive of type Boolean: // Only empty strings return false console.log(Boolean("") === false); console.log(Boolean("false") === true); console.log(Boolean("0") === true); // Only zero and NaN return false console.log(Boolean(NaN) === false); console.log(Boolean(0) === false); console.log(Boolean(-0) === false); // equivalent to -1*0 console.log(Boolean(-2) === true); // All objects return true console.log(Boolean(this) === true); console.log(Boolean({}) === true); console.log(Boolean([]) === true); // These types return false console.log(Boolean(null) === false); console.log(Boolean(undefined) === false); // equivalent to Boolean() The NOT operator evaluates its operand as a Boolean and returns the negation. Using the operator twice in a row, as a double negative, explicitly converts an expression to a primitive of type Boolean: console.log( !0 === Boolean(!0)); console.log(Boolean(!0) === !!1); console.log(!!1 === Boolean(1)); console.log(!!0 === Boolean(0)); console.log(Boolean(0) === !1); console.log(!1 === Boolean(!1)); console.log(!"" === Boolean(!"")); console.log(Boolean(!"") === !!"s"); console.log(!!"s" === Boolean("s")); console.log(!!"" === Boolean("")); console.log(Boolean("") === !"s"); console.log(!"s" === Boolean(!"s")); The ternary operator can also be used for explicit conversion: console.log([] == false); console.log([] ? true : false); // “truthy”, but the comparison uses [].toString() console.log([0] == false); console.log([0]? true : false); // [0].toString() == "0" console.log("0" == false); console.log("0"? true : false); // "0" → 0 ... (0 == 0) ... 0 ← false console.log([1] == true); console.log([1]? true : false); // [1].toString() == "1" console.log("1" == true); console.log("1"? true : false); // "1" → 1 ... (1 == 1) ... 1 ← true console.log([2] != true); console.log([2]? true : false); // [2].toString() == "2" console.log("2" != true); console.log("2"? true : false); // "2" → 2 ... (2 != 1) ... 1 ← true Expressions that use features such as post–incrementation (i++) have an anticipated side effect. JavaScript provides short-circuit evaluation of expressions; the right operand is only executed if the left operand does not suffice to determine the value of the expression. console.log(a || b); // When a is true, there is no reason to evaluate b. console.log(a && b); // When a is false, there is no reason to evaluate b. console.log(c ? t : f); // When c is true, there is no reason to evaluate f. In early versions of JavaScript and JScript, the binary logical operators returned a Boolean value (like most C-derived programming languages). However, all contemporary implementations return one of their operands