Skip to content

Instantly share code, notes, and snippets.

@marcmartino
Created July 31, 2012 21:57
Show Gist options
  • Save marcmartino/3221026 to your computer and use it in GitHub Desktop.
Save marcmartino/3221026 to your computer and use it in GitHub Desktop.
an attempt at multiple inheritence that feels crappy
var udemObj = {
set: function (options){
for(option in options){
if (this[option] !== undefined){
this[option] = options[option];
}
}
return this;
},
toObjectLiteral: function (){
var returnObject = {};
for (prop in this){
if (typeof this[prop] !== 'function'){
returnObject[prop] = this[prop]
}
}
return returnObject;
},
};
user = Object.create(udemObj);
user.template = null;
user.id = null;
user.arrayNum = null;
user.name = null;
user.classID = null;
user.sessionID = null;
user.toHtml = function (){};
var userClone = (Object.create(user));
userClone.set({id: 2, name: "Marc"});
userClone.arrayNum = 4;
userClone.toObjectLiteral();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment