Created
          October 6, 2013 04:20 
        
      - 
      
 - 
        
Save agonbina/6849479 to your computer and use it in GitHub Desktop.  
    Singelton pattern
  
        
  
    
      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
    
  
  
    
  | <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="[add your bin description]" /> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> | 
  
    
      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 Universe; | |
| (function() { | |
| var instance; | |
| Universe = function Universe() { | |
| if(instance) { | |
| return instance; | |
| } | |
| instance = this; | |
| this.start_time = 0; | |
| }; | |
| }()); | |
| var uni = new Universe(), | |
| uni2 = new Universe(); | |
| console.log(uni.start_time); | |
| console.log(uni2.start_time); | |
| uni.start_time = 100; | |
| console.log(uni.start_time); | |
| console.log(uni2.start_time); | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment