Skip to content

Instantly share code, notes, and snippets.

@cynx
Last active April 23, 2016 06:44
Show Gist options
  • Save cynx/b503a6df5d7c77bdd2c659e947d11207 to your computer and use it in GitHub Desktop.
Save cynx/b503a6df5d7c77bdd2c659e947d11207 to your computer and use it in GitHub Desktop.
var inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
};
function Manager(managerName) {
this.managerName = managerName;
}
Manager.prototype.getManagerName = function () {
return this.managerName;
}
function Team(managerName, teamName) {
this.teamName = teamName;
Team.super_.apply(this, arguments);
}
Team.prototype.getTeamDetails = function () {
return this.teamName + ' is managed by ' + this.managerName;
}
inherits(Team, Manager);
var obj = new Team('Klopp', 'LiverpoolFC');
console.log(obj.getTeamDetails()); //LiverpoolFC is managed by Klopp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment