I'm trying to practice JS OOP, particularly prototype inheritance, and I can't figure out why this JS Fiddle is returning undefined. Code below:
function Shape(name, edges) {
this.Name = name;
this.Edges = edges;
}
Shape.prototype.toString = function(){ return "Shape: " + this.Name;};
function Circle(radius) {
this.Radius = radius;
}
Circle.prototype.Area = function(){
return Math.PI * Math.pow(this.Radius, 2);
};
Circle.prototype = new Shape("Circle", 1);
Circle.prototype.constructor = Circle;
var circle = new Circle(5);
console.log(circle);
console.log(circle.toString());
console.log(circle.Area);
Could anyone shed some light on this please?