function extend() {
var target = arguments[0];
for (var i = 1; i < arguments.length; ++i) {
var options = arguments[i];
for (var prop in options) {
if (typeof options[prop] == 'object') {
target[prop] = extend({}, options[prop]);
}
else {
target[prop] = options[prop];
}
}
}
return target;
}
var a = {x: 'X', y: {yx: 'XX', yy: 'YY'}};
var b = {z: 'Z'};
var c = extend({}, a, b);
a.y.yx = 'TEST';
alert(c.y.yx);