Skip to content

Commit fe325f8

Browse files
Singletons can also have their own public methods.
Even though the public methods are accessible to the outer scope, they still retain their access to the privateVariable and privateFunction().
1 parent e505b58 commit fe325f8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

singleton.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ var singleton = function () {
55
/* perhaps do something with privateVariable... */
66
};
77

8-
return {};
8+
return {
9+
firstMethod: function (a, b) {
10+
/* privateVariable; */
11+
},
12+
13+
secondMethod: function (c) {
14+
/* privateFunction(c); */
15+
}
16+
};
917
}();

0 commit comments

Comments
 (0)