Created
August 3, 2014 20:53
-
-
Save flipjs/815603026e4a3801eef1 to your computer and use it in GitHub Desktop.
Truthey Tester by Angus Croll
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
var trutheyTester = function(expr) { | |
return expr ? "truthey" : "falsey"; | |
} | |
trutheyTester({}); //truthey (an object is always true) | |
trutheyTester(false); //falsey | |
trutheyTester(new Boolean(false)); //truthey (an object!) | |
trutheyTester(""); //falsey | |
trutheyTester(new String("")); //truthey (an object!) | |
trutheyTester(NaN); //falsey | |
trutheyTester(new Number(NaN)); //truthey (an object!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment