7 kyu

Singleton Pattern

8,105 of 8,200hculap

Description:

In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

Create an Singleton pattern, so there is one object in system.

Example:

var obj1 = new Singleton();
var obj2 = new Singleton();
obj1 === obj2; // => true
obj1.test = 1;
obj2.test; // => 1
Singleton
Object-oriented Programming
Fundamentals

Stats:

CreatedApr 17, 2014
PublishedApr 17, 2014
Warriors Trained13944
Total Skips1397
Total Code Submissions49500
Total Times Completed8200
JavaScript Completions8105
CoffeeScript Completions113
Total Stars175
% of votes with a positive feedback rating79% of 299
Total "Very Satisfied" Votes203
Total "Somewhat Satisfied" Votes68
Total "Not Satisfied" Votes28
Ad
Contributors
  • hculap Avatar
  • jhoffner Avatar
  • trashy_incel Avatar
Ad