Created
October 26, 2011 23:19
-
-
Save longlostnick/1318312 to your computer and use it in GitHub Desktop.
for prettier javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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