Last active
December 13, 2015 19:08
-
-
Save trukhinyuri/4960170 to your computer and use it in GitHub Desktop.
JavaScript Singleton without callee (works with strict mode)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Singleton; | |
| (function() { | |
| var instance; | |
| Singleton = function() { | |
| if (typeof instance !== 'undefined') | |
| return instance; | |
| //... | |
| return instance = this; | |
| }; | |
| })(); | |
| //creating instance with "new" keyword |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment