Skip to content

Instantly share code, notes, and snippets.

@pilgreen
Last active August 29, 2015 14:11
Show Gist options
  • Save pilgreen/c500ba4464a845f5dbf0 to your computer and use it in GitHub Desktop.
Save pilgreen/c500ba4464a845f5dbf0 to your computer and use it in GitHub Desktop.
Vanilla Object extension
Object.extend = function() {
var args = Array.prototype.slice.call(arguments);
var destination = args.shift();
var i = 0;
while(i < args.length) {
var source = args[i];
for(prop in source) {
if(Object.prototype.hasOwnProperty.call(source, prop)) {
if(typeof source[prop] === "object") {
destination[prop] = destination[prop] || {};
arguments.callee(destination[prop], source[prop]);
} else {
destination[prop] = source[prop];
}
}
}
i++;
}
return destination;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment