Created
June 24, 2019 14:39
-
-
Save prof3ssorSt3v3/f27d89685d4983d613128e7961a8a67d to your computer and use it in GitHub Desktop.
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
/** | |
* Create an example of a JavaScript Singleton. | |
* After the first object is created, it will return additional | |
* references to itself | |
*/ | |
let obj = (function () { | |
let objInstance; //private variable | |
function create() { //private function to create methods and properties | |
} | |
return { | |
}; | |
})(); | |
//let obj1 = obj.getInstance(); | |
// let obj2 = obj.getInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment