

InterviewSolution
Saved Bookmarks
1. |
Differentiate between ES6 class and ES5 function constructors. |
Answer» <html><body><table><tbody><tr><th>ES6 class</th><th>ES5 Function Constructors</th></tr></tbody><tbody><tr><td>ES6 class basically does the work of <a href="https://interviewquestions.tuteehub.com/tag/defining-2052307" style="font-weight:bold;" target="_blank" title="Click to know more about DEFINING">DEFINING</a> a new <a href="https://interviewquestions.tuteehub.com/tag/object-11416" style="font-weight:bold;" target="_blank" title="Click to know more about OBJECT">OBJECT</a> and appending functions to its prototype.</td><td>ES5 Function constructors work and look the same but the main difference is observed when the <a href="https://interviewquestions.tuteehub.com/tag/developer-25513" style="font-weight:bold;" target="_blank" title="Click to know more about DEVELOPER">DEVELOPER</a> uses the Inheritance property.</td></tr><tr><td>They can be considered as the syntax base for constructor functions.</td><td>These can only be <a href="https://interviewquestions.tuteehub.com/tag/executed-979171" style="font-weight:bold;" target="_blank" title="Click to know more about EXECUTED">EXECUTED</a> with the help of a new operator.</td></tr><tr><td>ES6 class allows the developers to instantiate objects using the new operator.</td><td>ES5 function constructors <a href="https://interviewquestions.tuteehub.com/tag/focus-25840" style="font-weight:bold;" target="_blank" title="Click to know more about FOCUS">FOCUS</a> on how the objects are instantiated.</td></tr><tr><td>They also ensure the developer that this keyword which is basically used inside the class only refers to the object that is being created by the developer.</td><td>ES5 function constructor focus on implementing the reusable object creation code. Any function can be used as a constructor.</td></tr></tbody></table></body></html> | |