生成器模式(Builder)


function extend(subclass, superclass) {
var F = function () {
};
F.prototype = superclass.prototype;
subclass.prototype = new F();
subclass.prototype.constructor = subclass;
subclass.super = superclass.prototype;

if (superclass.prototype.constructor === Object.prototype.constructor) {
superclass.prototype.constructor = superclass;
}
}

function mixin(targetObj, obj, deep) {
if (Object.prototype.toString.call(obj) !== '[object Object]') {
return;
}
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (deep === true) {
targetObj[i] = targetObj[i] || {};
mixin(targetObj[i], obj[i], deep);
} else {
targetObj[i] = obj[i];
}
}
}
}