Created
April 23, 2019 17:26
-
-
Save shisama/a7ff7539f406789048a01af56feec4a7 to your computer and use it in GitHub Desktop.
Class Fields - New JavaScript Features in Node.js v12
This file contains 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 IncreasingCounter { | |
#count = 0; | |
get value() { | |
console.log('Getting the current value!'); | |
return this.#count; | |
} | |
increment() { | |
this.#count++; | |
} | |
} | |
const counter = new IncreasingCounter(); | |
// counter.#count; // is Error | |
counter.increment(); | |
console.log(counter.value); // print '1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment