【发布时间】:2014-11-20 08:22:59
【问题描述】:
我有以下元代码
var Parent = function(){}
Parent.prototype.doSomething = function(){
console.log("As a parent I did like a parent");
}
var Child = function(){}
Child.prototype = new Parent();
Child.prototype.doSomething = function(){
console.log("As a child I did like a child");
//This is where I am not sure what to put
}
我想要的 2 行
As a child I did like a child
As a parent I did like a parent
当然第一个很简单,但我不确定如何/是否可以在父函数被覆盖后调用它。
【问题讨论】:
-
这里有一个例子:jsfiddle.net/zu097ep4
标签: javascript