Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Created June 20, 2021 10:24
Show Gist options
  • Save ashwinkumar2438/83435ce7a883358e9fb811f587144be5 to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/83435ce7a883358e9fb811f587144be5 to your computer and use it in GitHub Desktop.
function Life(medium){
this.medium=medium;
}
Life.prototype.eat=function(){return `get food from ${this.medium}`};
function Human(identity,medium){
Object.setPrototypeOf(Human,Life);
Life.call(this,medium);
this.identity=identity;
}
Human.prototype=Object.assign(Object.create(Life.prototype),{constructor:Human});
var developer=new Human('coder','soil');
developer.eat(); //@returns "get food from soil"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment