Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created April 24, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/7c5a3386a0a7acc2f36fc061700a0b9e to your computer and use it in GitHub Desktop.
Save isaacs/7c5a3386a0a7acc2f36fc061700a0b9e to your computer and use it in GitHub Desktop.
class Foo {
bar = 1
#baz = 0
get bazzer () {
return this.#baz
}
get barrier () {
this.#baz ++
return this.bar
}
}
const f = new Foo()
console.log('baz!', f.bazzer)
console.log('bar!', f.barrier)
console.log('baz!', f.bazzer)
console.log(f)
/* output:
baz! 0
bar! 1
baz! 1
Foo { bar: 1 }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment