Skip to content

Instantly share code, notes, and snippets.

@segunolalive
Created November 28, 2018 13:00
Show Gist options
  • Select an option

  • Save segunolalive/effe71d593a159c16f7ff6eb54e54074 to your computer and use it in GitHub Desktop.

Select an option

Save segunolalive/effe71d593a159c16f7ff6eb54e54074 to your computer and use it in GitHub Desktop.
class Arithmetic {
// inititalize the private property
#value;
// add getter for value
get val() {
return this.#value; // <== access the private property
}
// rest of the code truncated for clarity
}
a = new Arithmetic()
a.sum(1, 3, 6) // => { value: 10 }
.subtract(3) // => { value: 7 }
.add(4) // => { value: 11 }
.val // <== read the result of the computation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment