Created
January 28, 2017 20:53
-
-
Save anonymous/e5382373471cbe6ab687e402ac35107d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/necaqiz
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function Plant(){ | |
this.country = "india"; | |
this.isOrganic = true; | |
} | |
// end Plant constructor | |
function Fruit(name){ | |
this.name = name; | |
this.whereItGrows = function() { | |
console.log("it grows in " + this.country); | |
}; | |
} | |
// end fruit constructor | |
Plant.prototype.amIhealthy = function() { | |
console.log("I am super healthy"); | |
}; | |
Fruit.prototype = new Plant(); // make Plant prototype for Fruit | |
var banana = new Fruit("banana"); | |
console.log(banana.country); | |
console.log(banana.name); | |
banana.whereItGrows(); | |
banana.amIhealthy(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function Plant(){ | |
this.country = "india"; | |
this.isOrganic = true; | |
} | |
// end Plant constructor | |
function Fruit(name){ | |
this.name = name; | |
this.whereItGrows = function() { | |
console.log("it grows in " + this.country); | |
}; | |
} | |
// end fruit constructor | |
Plant.prototype.amIhealthy = function() { | |
console.log("I am super healthy"); | |
}; | |
Fruit.prototype = new Plant(); // make Plant prototype for Fruit | |
var banana = new Fruit("banana"); | |
console.log(banana.country); | |
console.log(banana.name); | |
banana.whereItGrows(); | |
banana.amIhealthy();</script></body> | |
</html> |
This file contains 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 Plant(){ | |
this.country = "india"; | |
this.isOrganic = true; | |
} | |
// end Plant constructor | |
function Fruit(name){ | |
this.name = name; | |
this.whereItGrows = function() { | |
console.log("it grows in " + this.country); | |
}; | |
} | |
// end fruit constructor | |
Plant.prototype.amIhealthy = function() { | |
console.log("I am super healthy"); | |
}; | |
Fruit.prototype = new Plant(); // make Plant prototype for Fruit | |
var banana = new Fruit("banana"); | |
console.log(banana.country); | |
console.log(banana.name); | |
banana.whereItGrows(); | |
banana.amIhealthy(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment