Skip to content

Instantly share code, notes, and snippets.

@krystalmonolith
Last active February 24, 2019 21:17
Show Gist options
  • Save krystalmonolith/0a1a0be81982858741a3e42bafe291d0 to your computer and use it in GitHub Desktop.
Save krystalmonolith/0a1a0be81982858741a3e42bafe291d0 to your computer and use it in GitHub Desktop.
Javascript Truth
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