Skip to content

Instantly share code, notes, and snippets.

@scriptschat
Created Sep 24, 2020
Embed
What would you like to do?
converting various values to boolean and verify how JavaScript behaves.
//if you try following line of code in chrome console
var a = new Boolean(undefined);
console.log(a);
//false
a = new Boolean(null);
console.log(a);
//false;
a = new Boolean(0);
console.log(a);
//false
a = new Boolean('0');
console.log(a);
//false
a = new Boolean(false);
console.log(a);
//false;
a = new Boolean('false');
console.log(a);
//true
a = new Boolean(NaN);
console.log(a);
//false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment