Created
November 28, 2018 13:00
-
-
Save segunolalive/effe71d593a159c16f7ff6eb54e54074 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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