Created
          June 16, 2011 13:52 
        
      - 
      
- 
        Save kpuputti/1029264 to your computer and use it in GitHub Desktop. 
    Lazy initialization for a function
  
        
  
    
      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 lazy = (function () { | |
| var initialized = false; | |
| var init = function () { | |
| // init code here | |
| }; | |
| return function () { | |
| if (!initialized) { | |
| init(); | |
| initialized = true; | |
| } | |
| // other functionality here | |
| }; | |
| }()); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment