Skip to content

Instantly share code, notes, and snippets.

@antonybudianto
Last active January 24, 2016 04:53
Show Gist options
  • Save antonybudianto/05c5f6176189ffa9e821 to your computer and use it in GitHub Desktop.
Save antonybudianto/05c5f6176189ffa9e821 to your computer and use it in GitHub Desktop.
# JavaScript Design Pattern
## Prototype Inheritance
function __extends(Child, Parent) {
Child.prototype = new Parent();
}
function Person(name) {
this.name = name;
this.hello = function() {
console.log(this.name);
}
}
function Student(name, studentId) {
Person.call(this, name)
this.studentId = studentId;
}
__extends(Student, Person);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment