Skip to content

Instantly share code, notes, and snippets.

@apburnes
Created February 21, 2014 05:03
Show Gist options
  • Select an option

  • Save apburnes/9129078 to your computer and use it in GitHub Desktop.

Select an option

Save apburnes/9129078 to your computer and use it in GitHub Desktop.
Gist from mistakes.io
function extend(obj) {
var args = Array.prototype.slice.call(arguments, 1);
args.forEach(function(item, ix, arr) {
for (prop in item) {
obj[prop] = item[prop];
}
})
return obj;
}
data = {};
obj1 = {
name: 'obj1',
value: 25,
multiply: function() {
return this.value * 2;
}
}
extend(data, obj1)
data.multiply()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment