Skip to content

Instantly share code, notes, and snippets.

@ilearnjavascript
Created March 27, 2019 23:39
Show Gist options
  • Save ilearnjavascript/7ee283b8b74f8b435494d73077426c81 to your computer and use it in GitHub Desktop.
Save ilearnjavascript/7ee283b8b74f8b435494d73077426c81 to your computer and use it in GitHub Desktop.
es6 - classes - 7.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);
}
var es5_Soldier = function (firstname, lastname, weapon) {
// call person object with current this context
es5_Person.call(this, firstname, lastname);
this.weapon = weapon;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment