【发布时间】:2018-09-06 09:51:39
【问题描述】:
我有 javascript 这个类:
class Student {
constructor(name, birthDate) {
this.name = name;
this.birthDate = birthDate;
}
get age() {
return 2018 - this.birthDate;
}
display() {
console.log(`name ${this.name}, birth date: ${this.birthDate}`);
}
}
console.log(Object.getOwnPropertyNames.call(Student));
我想获取属性列表名称。我尝试使用这样的东西:
Object.getOwnPropertyNames.call(Student)
但它不起作用。在这个例子中我应该得到的只是姓名和出生日期。没有其他方法或吸气剂。
【问题讨论】:
标签: javascript class ecmascript-6 properties