Last active
December 12, 2015 10:19
-
-
Save christopherscott/4758064 to your computer and use it in GitHub Desktop.
Psuedo classical inheritance in JavaScript
This file contains hidden or 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
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