Javascript Boolean Type Convert to Boolean via Boolean Constructor

Description

Javascript Boolean Type Convert to Boolean via Boolean Constructor

console.log( Boolean(-0) ); // false 
console.log( Boolean(0) ); // false 
console.log( Boolean(new Number(0)) ); // true 
console.log( Boolean(1) ); // true 
console.log( Boolean(NaN) ); // false 
console.log( Boolean(-1) ); // true 

console.log( Boolean(false) ); // false 
console.log( Boolean(true) ); // true 

console.log( Boolean(undefined) ); // false 
console.log( Boolean(null) ); // false 

console.log( Boolean(new String()) ); // true 
console.log( Boolean("") ); // false 
console.log( Boolean('a string') ); // true 
console.log( Boolean("true") ); // true 
console.log( Boolean("false") ); // true 

console.log( Boolean(function () {}) ); // true 
console.log( Boolean({}) ); // true 
console.log( Boolean([]) ); // true 



PreviousNext

Related