Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
RB.Object = {
// Douglas Crockford's technique for object extension
create: function(){
function F(){}
F.prototype = arguments[0];
var obj = new F();
// Add all the other arguments as mixins that
// 'write over' any existing methods
for (var i=1; i<arguments.length; i++) {
var methods = arguments[i];
if (typeof methods == 'object'){
for(methodName in methods) obj[methodName] = methods[methodName];
return obj;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.