Last active
February 24, 2019 21:17
-
-
Save krystalmonolith/0a1a0be81982858741a3e42bafe291d0 to your computer and use it in GitHub Desktop.
Javascript Truth
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
const x = { One:1, Zero:0, False:false, True:true, Undefined:undefined, Null:null, StringTrue:'true', StringFalse:'false', StringUndefined:'undefined', StringNull:'null' }; | |
console.log(x); | |
console.log('\n---------------------------------------------------------------------------\n'); | |
for (let i in x) { console.log(i + ':' + x[i] + ':' + (x[i] ? 'true' : 'false')) } | |
// { One: 1, | |
// Zero: 0, | |
// False: false, | |
// True: true, | |
// Undefined: undefined, | |
// Null: null, | |
// StringTrue: 'true', | |
// StringFalse: 'false', | |
// StringUndefined: 'undefined', | |
// StringNull: 'null' } | |
// | |
// --------------------------------------------------------------------------- | |
// | |
// One:1:true | |
// Zero:0:false | |
// False:false:false | |
// True:true:true | |
// Undefined:undefined:false | |
// Null:null:false | |
// StringTrue:true:true | |
// StringFalse:false:true | |
// StringUndefined:undefined:true | |
// StringNull:null:true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment