Full-Stack Developer Question:
Download Job Interview Questions and Answers PDF
Tell us the difference between classical inheritance and prototypal inheritance?
Answer:
The great thing about JavaScript is the ability to do away with the rigid rules of classical inheritance and let objects inherit properties from other objects.
☛ Classical Inheritance: A constructor function instantiates an instance via the “new” keyword. This new instance inherits properties from a parent class.
☛ Prototypal Inheritance: An instance is created by cloning an existing object that serves as a prototype. This instance—often instantiated using a factory function or “Object.create()”—can benefit from selective inheritance from many different objects.
☛ Classical Inheritance: A constructor function instantiates an instance via the “new” keyword. This new instance inherits properties from a parent class.
☛ Prototypal Inheritance: An instance is created by cloning an existing object that serves as a prototype. This instance—often instantiated using a factory function or “Object.create()”—can benefit from selective inheritance from many different objects.
Download Full-Stack Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Explain me the output of the code below. Explain your answer? | Tell me how would you empty the array below? |