Skip to content

Instantly share code, notes, and snippets.

@sag1v
Created November 25, 2019 14:27
Show Gist options
  • Save sag1v/b0ef22dc1ac4523402183a6cc4d4162d to your computer and use it in GitHub Desktop.
Save sag1v/b0ef22dc1ac4523402183a6cc4d4162d to your computer and use it in GitHub Desktop.
Markdium-JavaScript - The prototype chain in depth
class Player {
constructor(userName, score) {
this.userName = userName;
this.score = score;
}
setScore(newScore) {
this.score = newScore;
}
}
class PaidPlayer extends Player {
constructor(userName, score, balance) {
super(userName, score);
this.balance = balance;
}
setUserName(newName) {
this.userName = newName;
}
}
const player1 = new Player('sag1v', 700);
const paidPlayer = new PaidPlayer('sarah', 900, 5);
console.log(player1)
console.log(paidPlayer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment