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!
내가 _name
이 정의되지하지만 밖으로 동일한 기능을 작성하는 경우 다음이 정의가 아니라 왜 다음 DERIVED
기능에 Object._extends(DERIVED, BASE)
를 쓸 때?
'Object._extends (this, BASE)'시도 – jantimon
함수의 속성 인 prototype 속성을 설정해야하므로 'this'로 지정할 수 없습니다. DERIVED – xdevel2000