Last active
December 21, 2015 19:49
-
-
Save kmaida/6357260 to your computer and use it in GitHub Desktop.
Typecasting in JavaScript with !!
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 typeCast = function(string) { | |
if (!!string) { | |
document.write('<p>' + string + ': true</p>'); | |
} else { | |
document.write('<p>' + string + ': false</p>'); | |
} | |
}; | |
typeCast("Hello there"); | |
typeCast(""); | |
typeCast(null); | |
typeCast(undefined); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment