Created
          April 22, 2012 23:57 
        
      - 
      
- 
        Save raytiley/2467619 to your computer and use it in GitHub Desktop. 
    Design Phase 4 - Closure Example
  
        
  
    
      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 module = function(){ | |
| var privateVar = “I’m out of scope since function executes and returns”; | |
| //getPrivateVar is a property of the returned function. | |
| this.getPrivateVar = function() { | |
| return privateVar; | |
| } | |
| }(); // () causes anonymous function to automatically execute | |
| module.getPrivateVar === “I’m out of scope since function executes and returns”; //true | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment