Skip to content

Instantly share code, notes, and snippets.

@firedfox
Created June 3, 2012 02:55
Show Gist options
  • Save firedfox/2861273 to your computer and use it in GitHub Desktop.
Save firedfox/2861273 to your computer and use it in GitHub Desktop.
blarg i'm dead
Obj = function(){
this.properties = {'foo':'bar'};
}
Obj.prototype.returnTrue = function(){
return true;
}
var objInstance = new Obj();
console.log( objInstance.properties, objInstance.returnTrue());
var propNames = Object.getOwnPropertyNames(objInstance.__proto__);
console.log(propNames);
_.each(propNames, function(key, i){
console.log(key);
objInstance[key] = function(){
return false;
};
});
console.log( objInstance.properties, objInstance.returnTrue());
for (var i in objInstance) {
if (objInstance.hasOwnProperty(i) && typeof objInstance[i] === 'function') {
objInstance[i] = Obj.prototype[i];
}
}
console.log( objInstance.properties, objInstance.returnTrue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment