- [Narrator] Constructor functions provide a useful shortcut for building out objects. However, building out a large number of functions using constructor functions alone can have serious memory impact on your apps. Think about it. Your constructor creates one object with some custom properties, along with a few common properties and methods, then another, then another. After you've built, say, five objects, you have five separate copies in memory of each duplicate property and each duplicate method.
So for instance, in a travel app, I might create a prototype containing methods used to perform some common operations in calculating prices and booking. And then, I could build out objects using that prototype for use in different parts of the app. Think booking plane tickets, hotel rooms, car rentals, et cetera, each with their own custom needs, but sharing some core functionality. And then, when I build out those objects, their actual content is only the custom properties and methods they need, with references to the prototype for the shared functionality.
This aspect of prototypes, the fact that common keys and values are shared by reference, rather than by duplication, is key to the usefulness of prototypes.