Object.prototype.clone = function clone() {
var copy = (this instanceof Array) ? [] : {};
for (attr in this) {
if (!obj.hasOwnProperty(attr)) continue;
copy[attr] = (typeof this[i] == "object")?obj[attr].clone():obj[attr];
}
return copy;
};
var copy = (obj instanceof Array) ? [] : {};
for (attr in obj) {
if (!obj.hasOwnProperty(attr)) continue;
copy[attr] = (typeof obj[attr] == "object")?clone(obj[attr]):obj[attr];
}
return copy;
};