Created
November 19, 2019 19:29
-
-
Save sbstn-jmnz/fcfba975062cb5832e9ad03b6db16e77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Shape() { | |
this.name = 'Shape'; | |
this.toString = function () { | |
return this.name; | |
}; | |
} | |
function TwoDShape() { | |
this.name = '2D shape'; | |
} | |
function Triangle(side, height) { | |
this.name = 'Triangle'; | |
this.side = side; | |
this.height = height; | |
this.getArea = function () { | |
return this.side * this.height / 2; | |
}; | |
} | |
TwoDShape.prototype = new Shape(); | |
Triangle.prototype = new TwoDShape(); | |
var triangle = new Triangle(3,4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment