Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrei Li
34,475 PointsWhat is the practical application of Prototype? Why do we need Prototype in programming?
In previous courses I saw Prototype in JavaScript library. Does it mean that Prototype just extended by methods in JavaScript API? Or there is a something else.
1 Answer
Andrey Misikhin
16,529 PointsFor example, if you add function (method) into your class, then this function will be created every time for every instance of this class, even if you don't use it and it takes up more memory. If you add this function to prototype of your class, then will be used only one instance of this function for all objects of the class. Another feature, that you may create addition functionality of all existing objects of your class with just adding method into prototype of the class. And the main appointment, that inheritance in JS, under the hood, works through prototype.proto and new ES6 syntax for creating classes and inheritance is just "syntactic sugar".