DUtil = {};
DUtil.extend = function (destination, source) {
destination = destination || {};
if (source) {
for (var property in source) {
var value = source[property];
if (value !== undefined) {
destination[property] = value;
}
}
var sourceIsEvt = typeof window.Event == "function" && source instanceof window.Event;
if (!sourceIsEvt && source.hasOwnProperty && source.hasOwnProperty('toString')) {
destination.toString = source.toString;
}
}
return destination;
};
DObject = function () {
var Class = function () {
if (arguments && arguments[0] != null) {
this.construct.apply(this, arguments);
}
};
var extended = {};
var parent;
for (var i = 0; i < arguments.length; ++i) {
if (typeof arguments[i] == "function") {
parent = arguments[i].prototype;
} else {
parent = arguments[i];
}
DUtil.extend(extended, parent);
}
Class.prototype = extended;
return Class;
};
DUtil.extend用于扩展,DObject函数是用于继承(貌似也是扩展)?不知这个理解对不对?哪位能详细说下吗