Skip to content

Instantly share code, notes, and snippets.

@bpander
Created February 26, 2016 21:56
Show Gist options
  • Save bpander/ca8cfd3bd1eb8652dccd to your computer and use it in GitHub Desktop.
Save bpander/ca8cfd3bd1eb8652dccd to your computer and use it in GitHub Desktop.
// Base class
function Shape (x, y) {
this.x = x;
this.y = y;
}
// Rectangle extends Shape
function Rectangle (x, y, width, height) {
Shape.call(this, x, y);
this.width = width;
this.height = height;
}
Rectangle.prototype = Object.create(Shape.prototype);
Rectangle.prototype.constructor = Rectangle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment