Photo by Helloquence on Unsplash

Instantiation Patterns in JavaScript

Jennifer Bland
DailyJS
Published in
4 min readAug 10, 2017

--

Instantiation patterns are ways to create something in JavaScript. JavaScript provides four different methods to create objects. Regardless of which method you use, every method will provide the following functionality:

  • Create an object
  • Create methods and properties for that object

There are four instantiation patterns in JavaScript. They are:

  1. Functional
  2. Functional-shared
  3. Prototypal
  4. Pseudoclassical

Functional Instantiation

With functional instantiation, we first create a function. Inside the function we create an empty object and add properties and methods to it. We then return this object.

Every time the function is called we will have access to the methods that were created. Here is an example of functional instantiation:

Pros:
For most people that are learning JavaScript this is the method that they learned for creating a new object. For anybody reading your code, it is easy to understand because all the functions are contained within the…

--

--

Jennifer Bland
DailyJS

Software Engineer. Google Developers Expert. Keynote Speaker. Entrepreneur. Mountain Climber. Neil Diamond fan. World traveler. jenniferbland.com & codeprep.io