Javascript 调用父方法IE8

Javascript 调用父方法IE8,javascript,internet-explorer-8,Javascript,Internet Explorer 8,在其他浏览器中,我可以从\uuu proto\uu属性调用父方法。但它在IE8中不起作用。有没有办法在IE8中调用父方法 代码示例: function Foo() { this.init = function (msg) { alert("super method invoked"); }; this.toString = function () { return "Foo"; } } FooExtended.prototype

在其他浏览器中,我可以从
\uuu proto\uu
属性调用父方法。但它在IE8中不起作用。有没有办法在IE8中调用父方法

代码示例:

function Foo() {
    this.init = function (msg) {
        alert("super method invoked");
    };

    this.toString = function () {
        return "Foo";
    }
}

FooExtended.prototype = new Foo();

function FooExtended() {
    this.init = function (msg) {
        if (this.__proto__ == undefined) {
            alert("super invoke not supported")
        } else {
            this.__proto__.init(msg);
        }
    };

    this.toString = function () {
        return "FooExtended";
    }
}

var foo = new FooExtended();
foo.init();
而不是

  this.__proto__.init(msg)
试一试


这将在控制台
Foo.prototype.init
null中给出消息Object@Mrusful,好的,将Foo.prototype.init的定义移到构造函数之外,即将其声明为var并将其值指定为函数。另外,使用call代替apply。您知道
Foo.prototype.init(this)
footended.prototype.init(this)
之间的区别吗?其中
FooExtended
的上下文。如果看上面的例子。
  Foo.prototype.init.apply(this, msg);