What is a singleton pattern and where we can find it in AngularJS?

Technology CommunityCategory: AngularJSWhat is a singleton pattern and where we can find it in AngularJS?
VietMX Staff asked 3 years ago

Is a great pattern that restricts the use of a class more than once. We can find singleton pattern in angular in dependency injection and in the services.

In a sense, if the you do 2 times new Object() without this pattern, the you will be alocating 2 pieces of memory for the same object. With singleton pattern, if the object exists, it’ll be reused.