Skip to content

Commit 1e96289

Browse files
Singletons can have their own private variables.
There's no private keyword, but the way the closure scope works, but the object being returned will have access to privateVariable while the outer scope will not.
1 parent 78e0f91 commit 1e96289

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

singleton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var singleton = function () {
2+
var privateVariable;
23

34
return {};
45
}();

0 commit comments

Comments
 (0)