DEV Community

Harit Himanshu
Harit Himanshu

Posted on

2

Should we include methods in prototypes for ES6 Classes for performance?

So as I learn more about the Prototypal Inheritance in JS, I read the following in MDN article (read lines just above this link)

Note that when we are calling our constructor function, we are defining greeting() every time, which isn't ideal. To avoid this, we can define functions on…

Top comments (1)

Collapse
 
harittweets profile image
Harit Himanshu

*UPDATED ANSWER!! *

ES6 Classes puts the methods (also known as class methods) on Class Prototype.

See updated Question at stackoverflow.com/questions/579290...

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more