Created
November 25, 2019 14:27
-
-
Save sag1v/4ad878489d83e5292380ba56f64f0760 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
function PaidPlayer(userName, score, balance) { | |
this.balance = balance; | |
/* we are calling "Player" without the "new" operator | |
but we use the "call" method, | |
which allows us to explicitly pass a ref for "this". | |
Now the "Player" function will mutate "this" | |
and will populate it with the relevant properties */ | |
Player.call(this, userName, score); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment