Created
February 8, 2013 13:03
-
-
Save tecnocrata/4738932 to your computer and use it in GitHub Desktop.
Javascript Singleton with Self-writing Methods/Classes
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 SocketRouter = function() { | |
| console.log('Socket Router initialization'); | |
| SocketRouter = function() { | |
| console.log('But I already did something!'); | |
| }; | |
| }; | |
| var x1 = new SocketRouter(); | |
| var x2 = new SocketRouter(); | |
| var x3 = new SocketRouter();*/ | |
| function socketRouter() { | |
| console.log('Socket Router initialization'); | |
| socketRouter = function() { | |
| console.log('But I already did something!'); | |
| }; | |
| socketRouter.XX= function (){ | |
| console.log ('Calling XX'); | |
| }; | |
| }; | |
| var x1 = new socketRouter(); | |
| var x2 = new socketRouter(); | |
| var x3 = new socketRouter(); | |
| socketRouter.XX(); | |
| /*var doSomething = function(x) { | |
| console.log('Doing something useful initialization '+x); | |
| doSomething = function() { | |
| console.log('But I already did something!'); | |
| }; | |
| }; | |
| var a1 = new doSomething(1); | |
| var a2 = new doSomething(2); | |
| var a2 = new doSomething(3);*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment