Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active August 29, 2015 13:57
Show Gist options
  • Save dhigginbotham/9457606 to your computer and use it in GitHub Desktop.
Save dhigginbotham/9457606 to your computer and use it in GitHub Desktop.
bored extend... for kicks
var extend = function (dest) {
var args = Array.prototype.slice.call(arguments, 1),
ln = args.length;
for (var i=0;i<ln;++i) {
for (var o in args[i]) {
dest[o] = args[i][o];
}
};
return dest;
};
var dest = {
key: 'val2',
priv: 'val4'
};
var opts = {
key: 'val1',
priv: 'val3',
meow: 'cat'
};
var opts2 = {
key: 'val5',
meow: 'kitten'
};
console.log(extend(dest, opts, opts2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment