Skip to content

Instantly share code, notes, and snippets.

@longlostnick
Created October 26, 2011 23:19
Show Gist options
  • Save longlostnick/1318312 to your computer and use it in GitHub Desktop.
Save longlostnick/1318312 to your computer and use it in GitHub Desktop.
for prettier javascript
function _extend(obj) {
var sources = Array.prototype.slice.call(arguments, 1);
for (var i=0; i<sources.length; i++) {
var source = sources[i];
for (var prop in source) {
obj[prop] = source[prop];
}
}
}
// usage...
var Stuff = function() {
};
_extend(Stuff.prototype, {
method: function() {
// do stuff
}
});
var stuff = new Stuff();
stuff.method();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment