Skip to content

Instantly share code, notes, and snippets.

@tbranyen
Created January 18, 2012 22:08
Show Gist options
  • Save tbranyen/1636125 to your computer and use it in GitHub Desktop.
Save tbranyen/1636125 to your computer and use it in GitHub Desktop.
Minimalist extend function
function extend(destination) {
var prop, source;
var index = 0;
var length = arguments.length;
while (++index < length) {
source = arguments[index];
for (prop in source) {
destination[prop] = source[prop];
}
}
return destination;
}
@jdalton
Copy link

jdalton commented Jan 18, 2012

function extend(destination) { 
  var prop,
      source,
      index = 0,
      length = arguments.length;

  while (++index < length) {
    source = arguments[index];
    for (prop in source) {
      destination[prop] = source[prop];
    }
  }
  return destination;
}

@tbranyen
Copy link
Author

Thanks jdiddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment