Skip to content

Instantly share code, notes, and snippets.

@cynx
Last active April 23, 2016 06:43
Show Gist options
  • Save cynx/b1f4f6706c4e2e05c232b81b08055978 to your computer and use it in GitHub Desktop.
Save cynx/b1f4f6706c4e2e05c232b81b08055978 to your computer and use it in GitHub Desktop.
var inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
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()); //obj.getTeamDetails is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment