Skip to content

Instantly share code, notes, and snippets.

@sbstn-jmnz
Created November 19, 2019 19:29
Show Gist options
  • Save sbstn-jmnz/fcfba975062cb5832e9ad03b6db16e77 to your computer and use it in GitHub Desktop.
Save sbstn-jmnz/fcfba975062cb5832e9ad03b6db16e77 to your computer and use it in GitHub Desktop.
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