0

我有以下两个对象:

function circle(radius){
    this.radius = radius;    
    this.foo = function (){
        return "circle foo";};    
    return true;}

function pizza(){
    this.foo = function (){
        return "pizza foo";};
    return true;}

pizza.prototype = new circle(9);

当我执行以下操作时

var foo = myPizza.foo();

它按预期打印以下内容:

比萨饼

如何激活基类并从myPizza对象打印“circle foo”?

4

1 回答 1

2
pizza.prototype.foo.call(myPizza);   // outputs "circle foo"
于 2013-01-08T08:05:18.753 回答