【发布时间】:2020-09-24 22:43:15
【问题描述】:
请检查下面的代码,让我知道我错过了什么。
function Student() {
this.name = "John";
this.type = "Regular";
}
Student.prototype.changeType = function(givenType) {
this.type = givenType;
}
Student.prototype.changeType('Part-Time');
var William = new Student();
console.log(William.type); //Regular
控制台期望是Part-Time
【问题讨论】:
标签: javascript function-prototypes