Created
November 25, 2019 14:27
-
-
Save sag1v/55acdbc1906b25d6bcb395a38fb8d455 to your computer and use it in GitHub Desktop.
Markdium-JavaScript - The prototype chain in depth
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
class PaidPlayer extends Player { | |
constructor(userName, score, balance) { | |
// "this" is uninitialized yet... | |
// super refers to Player in this case | |
super(userName, score); | |
// under the hood super is implemented with Reflect.construct | |
// this = Reflect.construct(Player, [userName, score], PaidPlayer); | |
this.balance = balance; | |
} | |
setUserName(newName) { | |
this.userName = newName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment