function extend() {
var a = arguments, target = a[0] || {}, i = 1, l = a.length, deep = false, options;
if (typeof target === 'boolean') {
deep = target;
target = a[1] || {};
i = 2;
}
if (typeof target !== 'object' && !isFunction(target)) target = {};
for (; i < l; ++i) {
if ((options = a[i]) != null) {
for (var name in options) {
var src = target[name], copy = options[name];
if (target === copy) continue;
if (deep && copy && typeof copy === 'object' && !copy.nodeType) {
target[name] = extend(deep, src || (copy.length != null ? [] : {}), copy);
} else if (copy !== undefined) {
target[name] = copy;
}
}
}
}
return target;
}
выдергнул с ВК