Last active
November 8, 2019 07:52
-
-
Save przemuh/e6e5e36a1a71d5be3da7802deda7fef9 to your computer and use it in GitHub Desktop.
Egnyte Interview Prototype
This file contains 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 A(){ | |
if(!this.name) | |
this.name = 'A'; | |
} | |
A.prototype.sayHello = function(){ | |
console.log(this.name + ' says hello'); | |
}; | |
function B(){ | |
if(!this.name) | |
this.name = 'B'; | |
} | |
B.prototype = new A(); | |
function C(){ | |
if(!this.name) | |
this.name = 'C'; | |
} | |
C.prototype = Object.create(A.prototype); | |
const objB = new B(); | |
const objC = new C(); | |
objB.sayHello(); | |
objC.sayHello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment