Skip to content

Instantly share code, notes, and snippets.

@sag1v
Created November 25, 2019 14:27
Show Gist options
  • Save sag1v/55acdbc1906b25d6bcb395a38fb8d455 to your computer and use it in GitHub Desktop.
Save sag1v/55acdbc1906b25d6bcb395a38fb8d455 to your computer and use it in GitHub Desktop.
Markdium-JavaScript - The prototype chain in depth
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