Created
November 7, 2020 11:03
-
-
Save ranamahmud/3e8d1e18676b0bee1f5f999b77e097d6 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 values | |
// true, {}, [], any number, "0" | |
// "false" inside quote or any quoted string | |
// new Date() | |
// Infinity, -Infinity | |
// biginteger number | |
if (true) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if ({}) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if ([]) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if ("0") { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if ("false") { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if (Infinity) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
if (-Infinity) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
// condition is true | |
// 0, -0, 0n (big integer 0) | |
// "" | |
// false | |
// undefined | |
// null | |
// NaN | |
if (0) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
//condition is false | |
if (-0) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
//condition is false | |
if (0n) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
//condition is false | |
if (false) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
//condition is false | |
if (undefined) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} | |
//condition is false | |
if (NaN) { | |
console.log('condition is true'); | |
} else { | |
console.log('condition is false'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment