Last active
January 4, 2021 21:30
-
-
Save codingedgar/d370b1554e4b8fb487d1c3666501b6ac 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
console.group('Exemplifying the difference between falsy and nullish'); | |
const catWithNoChars = new Cat(''); | |
console.assert(catWithNoChars.name === ''); | |
// '' is falsy but no nullish | |
if (!catWithNoChars.name) { | |
catWithNoChars.name = 'Pepo'; | |
} | |
console.assert(catWithNoChars.name === ''); // Assertion failed | |
console.groupEnd(); | |
/* | |
Console: | |
Exemplifying the difference between falsy and nullish | |
get called | |
get called | |
set called Pepo | |
get called Pepo | |
Assertion failed | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment