inheritance extend

by Nabaraj Saha

HTML

<div id="div1"></div>

JavaScript

function extend2(Child, Parent) {
	var p = Parent.prototype;
	var c = Child.prototype;
	for (var i in p) {
		c[i] = p[i];
	}
	c.uber = p;
}

var Shape = function(){};
var TwoDShape = function(){};
Shape.prototype.name = 'shape';
Shape.prototype.toString = function(){return this.name;};

extend2(TwoDShape, Shape);
var td = new TwoDShape();
writediv("div1",td.name );

function writediv(a,b){
	document.getElementById(a).innerHTML=b;
}