Created
September 4, 2019 16:38
-
-
Save rintoandrews90/df9f31eb1bb47b4cae1f40841b4a96f1 to your computer and use it in GitHub Desktop.
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
/********************** | |
* Truthy & falsy values | |
***/ | |
// falsy values : undefined, null, 0, '', NaN | |
// truthy valyes: not falsy values | |
var height; | |
if (height || height === 0 ) { | |
console.log('value defined'); | |
} else { | |
console.log('undefined'); | |
} | |
var txt = ''; | |
if (txt || txt === 0 ) { | |
console.log('value defined'); | |
} else { | |
console.log('undefined str'); | |
} | |
// string '23' converted to int so its true | |
var age = 23; | |
if (age == '23') { | |
console.log('true'); | |
} | |
// string '23' will not be converted to int so its false | |
if (age === '23') { | |
console.log('true'); | |
}else{ | |
console.log('false') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment