__proto__
在其他浏览器中,我可以从属性调用父方法。但它在 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();