Last active
December 4, 2022 06:48
-
-
Save zandroid/5687521 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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