Skip to content

Instantly share code, notes, and snippets.

@codingedgar
Last active January 4, 2021 21:32
Show Gist options
  • Save codingedgar/eac8e5a3ea6784d9c7e77364e136a7c0 to your computer and use it in GitHub Desktop.
Save codingedgar/eac8e5a3ea6784d9c7e77364e136a7c0 to your computer and use it in GitHub Desktop.
const aNewCat = new Cat();
aNewCat.name ??= 'Artemis';
console.assert(aNewCat.name === 'Artemis');
aNewCat.name ??= 'Nirvana';
console.assert(aNewCat.name === 'Artemis');
console.groupEnd();
/*
Console:
Logical Nullish Assignment
get called undefined
set called Artemis
get called Artemis
get called Artemis
get called Artemis
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment