🔸class field
JS ⟩ class ⟩ definition ⟩ class fields
class fields 指寫在 class definition 中,但在 constructor()
外面的 instance properties。據說這種新語法是為了改良原有的constructor()
語法,讓物件屬性更突出、更易於集中管理而設計的做法。
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()
👉 更詳細內容,請看: override class fields
Last updated