Skip to content

Instantly share code, notes, and snippets.

@yajurvendrasinh
Forked from anonymous/index.html
Created January 28, 2017 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yajurvendrasinh/116bd3bd514d095c11c74e582d8070f4 to your computer and use it in GitHub Desktop.
Save yajurvendrasinh/116bd3bd514d095c11c74e582d8070f4 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/necaqiz
<!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>
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