How to implement Shape class above Circle ? I mean Circle and Rectangle class should be inherited from Shape.
I will be happy if someone give real code 🙂
here i made Circle class with prototype definition as well.
function Circle(radius){
this.radius = radius;
Circle.prototype.area = function(){return (Math.PI)* (Math.pow(this.radius,2));};
}
var circle1 = new Circle(5);
circle1.radius; //5
circle1.area() //78.53
You can use prototype to implement inheritance in JS for ex :
In your case define shape class then extend it like this :
This will give you more info about the same
:- http://phrogz.net/js/classes/OOPinJS2.html