Singletons in JavaScript

How to implement them and whether they’re actually useful

Bret Cameron

--

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…

--

--

Bret Cameron

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