问题描述
var Ctor = function (){};
var baseCreate = function (prototype) {
if(!_.isObject(prototype)) {
return {};
}
if(nativeCreate) {
return nativeCreate(prototype);
}
Ctor.prototype = prototype;
var result = new Ctor;
Ctor.prototype = null;
return result;
};
(Ctor.prototype = prototype)使用原型继承再(var result = new Ctor)实例化,最后(Ctor.prototype = null)为什么要清空在原型上添加的方法。
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…