Skip to content

Instantly share code, notes, and snippets.

@codingedgar
Last active January 4, 2021 21:32
Show Gist options
  • Save codingedgar/d44152224b7b410a84117dfff3b03a0f to your computer and use it in GitHub Desktop.
Save codingedgar/d44152224b7b410a84117dfff3b03a0f to your computer and use it in GitHub Desktop.
console.group('Eager Setter with Nullish Coalescing Operator');
const anotherRandomCat = new Cat('Pepo');
anotherRandomCat.name = anotherRandomCat.name ?? 'Luna'
console.assert(anotherRandomCat.name === 'Pepo');
console.groupEnd();
/*
Console:
Eager Setter with Nullish Coalescing Operator
get called Pepo
set called Pepo
get called Pepo
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment