prototype

by SriSri M

HTML

<input id="demo" type="text" />

JavaScript

function plants(type,span){
	this.type = "herbs";
  this.span = 7;
}
plants.prototype.showName = function(){
	console.log("Name is"+" "+this.name);
}
function fruits(fruitname){
  this.name = fruitname;
}
fruits.prototype = new plants();
var myfruit = new fruits("apple");

var x = document.getElementById('demo');
x.myfruit.name();