Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
Last active July 22, 2021 07:47
Show Gist options
  • Save stevenocchipinti/01c5ade4bcf8f3a213f21a10cb945904 to your computer and use it in GitHub Desktop.
Save stevenocchipinti/01c5ade4bcf8f3a213f21a10cb945904 to your computer and use it in GitHub Desktop.
A simple demonstration of classes in es6
//
// Person.js
//
// This is a simple Person class.
//
// It doesn't do much, but it demonstrates the use of ES6 classes. Note that
// this code will most likely not work in old browsers directly. To 'compile'
// this down to the more widely accepted ES5, you could use Babel.
//
class Person {
constructor(name) {
this.name = name;
}
say(text) {
console.log(`${this.name} says: ${text}`);
}
}
const bob = new Person('Bob');
bob.say("Hello World");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment