87,901
社区成员
发帖
与我相关
我的任务
分享
function Base() {}
Base.prototype.getYear = function() {
return 2015;
}
function Derived() {
year = 2016;
}
Derived.prototype = new Base();
Derived.prototype.getYear = function() {
return 2017;
}
var ins = new Derived();
console.log(ins.getYear());
console.log(ins.prototype.getYear());
console.log(ins.prototype.getYear());
是ins.prototype未定义。
console.log(ins.__proto__.getYear());
// or (JS2015)
console.log(Object.getPrototypeOf(ins).__getYear());