Skip to content

Instantly share code, notes, and snippets.

@ilearnjavascript
Created March 27, 2019 23:38
Show Gist options
  • Save ilearnjavascript/08b59458eeed32bc9a8391eb71d4cbde to your computer and use it in GitHub Desktop.
Save ilearnjavascript/08b59458eeed32bc9a8391eb71d4cbde to your computer and use it in GitHub Desktop.
es6 - classes - 5.js
var es5_Person = function (firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
var john = new es5_Person('John', 'Doe');
es5_Person.prototype.greet = function () {
console.log('Hello I am ' + this.firstname + ' ' + this.lastname);
}
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