Created
September 9, 2020 10:48
-
-
Save night-fury-rider/19331674ae2bca8d5a42a168fc35daac to your computer and use it in GitHub Desktop.
Design Pattern - Prototype
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
var Cricketer = function(name, runs) { | |
this.name = name; | |
this.runs = runs; | |
}; | |
Cricketer.prototype.getPlayerDetails = function() { | |
return this.name + ' has scored ' + this.runs + ' runs'; | |
} | |
var player1 = new Cricketer('Sachin', 18426); | |
console.log(player1.getPlayerDetails()); // Sachin has scored 18426 runs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment