Created
June 20, 2021 10:24
-
-
Save ashwinkumar2438/83435ce7a883358e9fb811f587144be5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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