Created
          April 26, 2011 17:01 
        
      - 
      
- 
        Save heronmedeiros/942662 to your computer and use it in GitHub Desktop. 
    JS Closure
  
        
  
    
      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
    
  
  
    
  | function makeAdder(x){ | |
| return function(y){ | |
| return x+y; | |
| }; | |
| } | |
| var add5 = makeAdder(5); | |
| var add10 = makeAdder(10); | |
| alert(add5(2)); | |
| alert(add10(2)); | |
| alert( makeAdder(5)(2) ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment