Skip to content

Instantly share code, notes, and snippets.

@przemuh
Last active November 8, 2019 07:52
Show Gist options
  • Save przemuh/e6e5e36a1a71d5be3da7802deda7fef9 to your computer and use it in GitHub Desktop.
Save przemuh/e6e5e36a1a71d5be3da7802deda7fef9 to your computer and use it in GitHub Desktop.
Egnyte Interview Prototype
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