DEV Community

Discussion on: Prototype in Javascript - 01 - Object creation

Collapse
 
ferluisxd profile image
Luis Vilca

Hey I have a question having an object with user1.increaseScore()
Does this issue you mention under the last paragraph happens with Classes as well?
For example if User was a class (with a constructor) and has the increaseScore() method. Is not memory efficent as well?

Collapse
 
kabir4691 profile image
Kabir Nazir

I'm glad you asked this question. The short answer is that it is memory efficient. But one needs to remember that class in JavaScript is just syntactic sugar and basically does the same thing as creating an object through a function under the hood. I shall be talking about prototypes in classes in detail in part 4 of this series!

Collapse
 
ferluisxd profile image
Luis Vilca

Ok you won a follow

Thread Thread
 
kabir4691 profile image
Kabir Nazir

Glad you found my content helpful, Luis!