Javascript Design Patterns: Singleton Pattern

Category : code

Date : March 20, 2016

Singleton is design pattern which is used to restrict an object to have a single instance throught the application. In other words, In Singleton pattern there will be only one instance of a constructor function and if you try to instantiate second one, the first instance that was already created will be returned.

Another cool thing about singletons are in frameworks like angular whenever you create a service by default it is always a singleton.

If you have any questions, comments or suggestions, feel free to join the discussion below!