Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created April 1, 2010 20:15
Show Gist options
  • Save knowuh/352316 to your computer and use it in GitHub Desktop.
Save knowuh/352316 to your computer and use it in GitHub Desktop.
Object.prototype.clone = function(isDeep) {
var key;
var return_results = {};
if (isDeep && (typeof this == "object")) {
for (key in this) {
return_results[key] = this[key].clone();
}
}
else {
return_results = this;
}
return return_results;
};
Object.prototype.merge = function(otherObject) {
var key;
for (key in otherObject) {
if (typeof otherObject[key] != "function") {
this[key] = otherObject[key].clone();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment