We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 355812c commit 62fbdecCopy full SHA for 62fbdec
singelton.js
@@ -0,0 +1,26 @@
1
+// The Singleton Pattern limits the number of instances of a particular object to just one.
2
+// http://www.dofactory.com/javascript/singleton-design-pattern
3
+
4
+//The instances in clouser.
5
6
+function Singelton() {
7
+ var instance = this;
8
9
+ Singelton = function() {
10
+ return instance
11
+ };
12
13
+ Singelton.prototype = this;
14
15
+ instance = new Singelton();
16
17
+ instance.constructor = Singelton;
18
19
+ return instance;
20
+}
21
22
+var x = new Singelton();
23
+x.someProp = true;
24
+var y = new Singelton();
25
+y.someProp = false;
26
+x.someProp // false
0 commit comments