0
如果我有:调用函数范围之谜
Object._extends = function(Derived, Base)
{
Derived.prototype = new Base();
Derived.prototype.constructor = Derived;
Derived.uber = Derived.prototype;
}
var BASE = function()
{
this._name = "BASE"
}
var DERIVED = function()
{
Object._extends(DERIVED, BASE)
this._age = 3;
}
// Object._extends(DERIVED, BASE) if I write here all is ok!!!
alert(new DERIVED()._name) // undefined!
当我写Object._extends(DERIVED, BASE)
到DERIVED
功能则_name
是不确定的,但如果我写相同的功能出来那么它是不是不确定的,但为什么呢?
尝试'Object._extends(this,BASE)' – jantimon 2009-10-13 11:43:38
我不能用'this',因为我必须设置prototype属性,它是函数DERIVED的一个属性 – xdevel2000 2009-10-13 13:01:45