Last active
August 29, 2015 14:20
-
-
Save pvamshi/57826de97821230a0999 to your computer and use it in GitHub Desktop.
True or False
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Falsy values : "" , '' , 0 , undefined , null , NaN , false | |
*/ | |
function evalTruth(a) { | |
if (a) { | |
console.log('TRUE'); | |
} else { | |
console.log('FALSE'); | |
} | |
} | |
console.log("0"); | |
evalTruth(0); | |
console.log("----"); | |
console.log("!0"); | |
evalTruth(!0); | |
console.log("----"); | |
console.log("!!0"); | |
evalTruth(!!0); | |
console.log("----"); | |
console.log("''"); | |
evalTruth(''); | |
console.log("----"); | |
console.log("'0'"); | |
evalTruth('0'); | |
console.log("----"); | |
console.log("'0'==false"); | |
evalTruth('0'==false); | |
console.log("----"); | |
console.log("'0'===false"); | |
evalTruth('0'===false); | |
console.log("----"); | |
console.log("0 || 12+4 "); | |
console.log(0 || 12+4); | |
console.log("----"); | |
console.log("0 && 12+4 "); | |
console.log(2 && 12+4); | |
console.log("----"); | |
console.log("0 && 12+4 "); | |
console.log(2 && 12+4); | |
console.log("----"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment