Skip to content

Instantly share code, notes, and snippets.

@ppraksa
Last active March 31, 2017 10:02
Show Gist options
  • Save ppraksa/8d3b830b26a9d74cf980de73c0d5e704 to your computer and use it in GitHub Desktop.
Save ppraksa/8d3b830b26a9d74cf980de73c0d5e704 to your computer and use it in GitHub Desktop.
Like a parasite
Object.prototype.parasiteCopy = function(obj, args) {
if(typeof obj.constructor === 'function') {
obj.apply(this, args);
}
}
var Plant = function(colour,roots) {
this.colour = colour;
this.roots = roots
}
var Letuce = { hasLeavs: true, height: 13 }
Letuce.parasiteCopy(Plant, ['green',true]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment