๐ธprivate member
JS โฉ value โฉ object โฉ class โฉ member โฉ private
private members are not inheritedโ
class A {
// โญ๏ธ private members // # means "private"
#a; // this.#a = undefined
#b = 0; // this.#b = 0
get #c() { return 0 } // this.#c (private getter)
#d() { ... } // this.#d() (private method)
// โญ๏ธ private static members
// (accessable only within the class body)
static #staticProp; // A.#staticProp
static get #CONST() { return 0 } // A.#CONST
static #staticMethod() { ... } // A.#staticMethod()
}never use "this" to access a private static field,
always use the direct class name.
๐ ๐ 2ality.com โฉ ECMAScript proposal: private class fields
supporting environments
Last updated
Was this helpful?