-
-
Save ilearnjavascript/7ee283b8b74f8b435494d73077426c81 to your computer and use it in GitHub Desktop.
es6 - classes - 7.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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