Created
May 18, 2019 23:30
-
-
Save iskenxan/142628c5698f415e58431bbc68aae7e1 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
| function Hedgehog () { | |
| let speed = 10000; // this is private | |
| this.name = 'Sonic'; | |
| this.zoom = function () { | |
| // both name and speed are accessible from here | |
| console.log(`${this.name} zooms with the speed of ${speed} miles per second!`); | |
| } | |
| } | |
| const sonic = new Hedgehog(); | |
| sonic.zoom(); | |
| console.log(sonic.name) //valid value | |
| console.log(sonic.speed) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment