Skip to content

Instantly share code, notes, and snippets.

@christopherscott
Last active December 12, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherscott/4758064 to your computer and use it in GitHub Desktop.
Save christopherscott/4758064 to your computer and use it in GitHub Desktop.
Psuedo classical inheritance in JavaScript
function Person(name) {
this.name = name;
}
Person.prototype.speak = function () {
console.log(this.name);
};
function Employee(name) {
this.name = name;
}
Employee.prototype = new Person();
Employee.prototype.work = function () {
console.log(this.name + ' is workning');
};
var a = new Employee('chris');
a.speak();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment