Created
May 26, 2019 10:15
-
-
Save jkasaudhan/da13ade1209d34738eaf3698bdf3c5cb to your computer and use it in GitHub Desktop.
Private class field in js
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 Person { | |
#salary = '12345'; // => private class field | |
getSalary() { | |
this.#salary; | |
} | |
} | |
class jack = new Person(); | |
console.log(jack.#salary); // will prompt syntax error as it is private filed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment