jjzjj

childCtor

全部标签

javascript - 为什么在进行 Javascript 继承时要创建一个临时构造函数?

为什么goog.inherits来自GoogleClosureLibrary看起来像这样:goog.inherits=function(childCtor,parentCtor){functiontempCtor(){};tempCtor.prototype=parentCtor.prototype;childCtor.superClass_=parentCtor.prototype;childCtor.prototype=newtempCtor();childCtor.prototype.constructor=childCtor;};而不是goog.inherits=functio