Created
May 18, 2019 23:31
-
-
Save iskenxan/2e2f020ec1a47c1d8599d16f1d423ab6 to your computer and use it in GitHub Desktop.
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
| class Hedgehog { | |
| constructor() { | |
| let speed = 10000; //this is private | |
| this.name = 'Sonic'; | |
| this.zoom = function () { | |
| // can access both name and speed from here | |
| console.log(`${this.name} zooms with the speed of ${speed} miles per second!`); | |
| } | |
| } | |
| jump() { | |
| // cannot access speed from here | |
| console.log(`${this.name} jumps on top of the building!`); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment