Skip to content

Instantly share code, notes, and snippets.

@zandroid
Last active December 4, 2022 06:48
Show Gist options
  • Save zandroid/5687521 to your computer and use it in GitHub Desktop.
Save zandroid/5687521 to your computer and use it in GitHub Desktop.
function Rect(width, height) {
this.width = width;
this.height = height;
}
Rect.prototype.type = function() { return "rect"; };
function Square(width) {
return new Rect(width, width);
}
Square.prototype.type = function() { return "square"; };
sq = new Square(12);
log(sq.type()); //=> ???
log(sq instanceof Square); //=> ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment