Skip to content

Instantly share code, notes, and snippets.

@ilearnjavascript
Created March 27, 2019 23:38
Show Gist options
  • Save ilearnjavascript/7a95fc91a76971af13d586a5ec4b1670 to your computer and use it in GitHub Desktop.
Save ilearnjavascript/7a95fc91a76971af13d586a5ec4b1670 to your computer and use it in GitHub Desktop.
es6 - classes - 6.js
class es6_Person {
constructor(firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
greet() {
console.log('Hello I am ' + this.firstname + ' ' + this.lastname);
}
}
var john = new es6_Person('John', 'Doe');
john.greet(); // outputs: Hello my name is John Doe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment