๐ธclass field
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS โฉ class โฉ definition โฉ class fields
class fields are defined on the instance, not on the prototype.
๐ MDN โฉ arrow functions used as methods
The class fields are initialized:
base class: before constructor()
derived class: immediately after super()
๐ ๆด่ฉณ็ดฐๅ งๅฎน๏ผ่ซ็๏ผ
class X {
// โญ๏ธ static getters & setters
static get a(){ return this._a || 0 } // this === X
static set a(value){ this._a = value } // this === X
}
X.a // get: 0.0
X.a = 3 // set: 3.0
X.a // get: 3.0