class MyClass {
prop = value; // 属性
// 构造器
constructor(name) {
this.name = name
}
// method
click = () => {
alert(this.value);
}
get name() {
return this._name
} // getter 方法
set name(value) {
this._name = value
} // setter 方法
// 有计算名称(computed name)的方法(此处为 symbol)
‘say’ + ‘Hi’ {
alert(“Hello”);
}
}
alert(Object.getOwnPropertyNames(User.prototype)); // constructor, sayHi