Prototype Pattern

In this lesson, we will go over the prototype pattern in detail using a coding example.

What is the prototype pattern?

The prototype creational pattern is used to instantiate objects with some default values using an existing object. It clones the object and provides the existing properties to the cloned object using prototypal inheritance.

In prototypal inheritance, a prototype object acts as a blueprint from which other objects inherit when the constructor instantiates them. Hence, any properties defined on the prototype of a constructor function will also be present in the cloned object it creates.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.