- We can append key to objects using the “dot” syntax,
- We create a new object instance using the
The pattern usually follows,
- Use a function closure to create an object-like structure, this is our “constructor function,”
- Append variable values to an object instance using the
- Append shared object methods to the Prototype object.
Altogether we would get something,
Though simple in its execution, depending on the nature of the problem at hand the constructor pattern could lead to a lot of unnecessary bloat. In the coming weeks, we will see constructors again and again in some form or another, as they often form a smaller part of more elaborate patterns.
All the best,