DEV Community

Discussion on: Singleton Pattern in Javascript

Collapse
 
mindplay profile image
Rasmus Schultz

The singleton pattern is an anti pattern - see the "Criticism" section in the Wikipedia article for a brief summary of all the reasons why:

en.wikipedia.org/wiki/Singleton_pa...

Teaching this pattern without a clear warning should be considered harmful - using this pattern will lead to endless refactoring and makes your software untestable.

Please look up articles about dependency injection, and inversion of control, and learn that instead.