<html><head>
<title>無標題文檔</title></head><body></body></html><script>
function People() { this.age = 23;
}
People.prototype = { eat: function () {
alert('123');
}
}; function Student(name, skin) {
People.apply(this, arguments);
} var test = new Student('張三', '黃皮膚'); console.log(test.age);
test.eat();</script>為什么test.eat()方法會有錯誤,但是test.age又能正常輸出。
構造函數繼承的一個問題
ABOUTYOU
2018-09-10 15:34:24