Skip to content

Instantly share code, notes, and snippets.

@pixelsnob
Created September 16, 2018 03:12
Show Gist options
  • Save pixelsnob/d1f66963fb4b0b8c3aa0598100672b80 to your computer and use it in GitHub Desktop.
Save pixelsnob/d1f66963fb4b0b8c3aa0598100672b80 to your computer and use it in GitHub Desktop.
function Parent() {
console.log('hi from parent');
}
Parent.prototype.exampleMethod = function() {
console.log('hi from parent method');
};
function Child() {
Parent.call(this);
console.log('hi from child');
}
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
Child.prototype.sayHey = function() {
console.log('hey!');
};
function TeacherMixin() {
console.log('teacher mixin');
this.type = 'teacher';
this.test = function() {};
}
function ChildTeacher() {
TeacherMixin.call(this);
Child.call(this);
};
ChildTeacher.prototype = Object.assign(Child.prototype, TeacherMixin.prototype);
const child_teacher = new ChildTeacher;
child_teacher.exampleMethod();
child_teacher.sayHey();
child_teacher.test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment