5 Matching Annotations
- Jun 2021
-
developer.mozilla.org developer.mozilla.org
-
The encapsulation is enforced by the language. It is a syntax error to refer to # names from out of scope.
-
-
stackoverflow.com stackoverflow.com
-
in languages (like JavaScript and Java) where external objects do have direct access to instance vars
-
-
stackoverflow.com stackoverflow.com
-
Note: there’s no way to define private methods, getters and setters. but a proposal is there https://github.com/tc39/proposal-private-methods
-
-
babeljs.io babeljs.io
-
Private instance accessors (getters and setters)
-
class Person { #firstname = "Babel"; #lastname = "JS"; get #name() { return this.#firstname + " " + this.#lastname; } sayHi() { alert(`Hi, ${this.#name}!`); } }
-