Photo by Adeolu Eletu on Unsplash

My Aim




Photo by Nicholas Barbaros on Unsplash

When we need a single instance of an object, of a specific class, to exist in our application, we use the Singleton pattern. Now, the pattern itself is frowned upon in some circles and is seen as an anti-pattern.

Some of the reasons the Singleton is seen as an anti-pattern are:

  • It can be technical debt in disguise. The assumption that there will only be a need for one instance of the class during the lifetime of the application can be falsified in the future. This can lead to tedious refactoring.
  • The introduction of global state into the application.
  • The…

Photo by Matt Schwartz on Unsplash

The Aim

The Approach

I constrain the type parameter T to represent a…

Photo by John Doyle on Unsplash

My Aim


Photo by Thomas Kelley on Unsplash


  • With Array literal initialization, such as in let myArray = [1,2]
  • With Array initialization with undefined, as in new Array(arrayLength)
  • With Array initialization with given elements, as in new Array(el1,el2)
  • With the Array.prototype.of method, as in // -> [7]

This being known, there eventually comes a time when a learning javascript developer will need to have more control over the initialization of arrays. In the coming sections we will explore common array initialization questions, as well as some solutions for the power javascript developer to-be.

Question: How to initialize an array with the same value?

Photo by Ricky Kharawala on Unsplash


Before going any further, DI can be defined as:

[A] technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service)…

Photo by Gilly Stewart on Unsplash

In a previous article, I describe an approach to a generic PHP Singleton pattern that can be summarized by the following diagram:

Patrick Assoa Adou

Solutions Architect and Coder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store