Skip to content

Instantly share code, notes, and snippets.

@iskenxan
Created May 18, 2019 23:31
Show Gist options
  • Select an option

  • Save iskenxan/2e2f020ec1a47c1d8599d16f1d423ab6 to your computer and use it in GitHub Desktop.

Select an option

Save iskenxan/2e2f020ec1a47c1d8599d16f1d423ab6 to your computer and use it in GitHub Desktop.
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