Singletons in JavaScript

How to implement them and whether they’re actually useful

Photo by Scott Webb on Unsplash

A singleton is a function or class which can have only one instance. It’s a design pattern popularised by the “Gang of Four” in their influential Design Patterns. However, the singleton is one of several patterns in the book which have been criticised. Some are regarded as anti-patterns, while others are only useful in…

--

--

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
Bret Cameron

Bret Cameron

4.7K Followers

Writer and developer based in London. On Medium, I write about JavaScript and web development 💻