See following example;
You could skip the ternary, and evaluate the “not not x”, e.g. !!x
.
If x is undefine, !x is true, so !!x becomes false again. If x is true !x is false so !!x is true.
function logBool(x) {
x = !!x;
console.log(x);
}
var a, b = false, c = true;
logBool(a); // false
logBool(b); // false
logBool(c); // true

