Created
September 16, 2018 03:12
-
-
Save pixelsnob/d1f66963fb4b0b8c3aa0598100672b80 to your computer and use it in GitHub Desktop.
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 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