Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created June 24, 2019 14:39
Show Gist options
  • Save prof3ssorSt3v3/f27d89685d4983d613128e7961a8a67d to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/f27d89685d4983d613128e7961a8a67d to your computer and use it in GitHub Desktop.
/**
* 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