DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Harit Himanshu
Harit Himanshu

Posted on

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 Author

*UPDATED ANSWER!! *

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

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

"I made 10x faster JSON.stringify() functions, even type safe"

☝️ Must read for JS devs