Created
March 25, 2012 22:43
-
-
Save mahmoud/2200504 to your computer and use it in GitHub Desktop.
brief closure demonstration
This file contains 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 greet = function(greeting) { | |
var full_greeting = greeting+', '; | |
var greet_name = function(name) { | |
console.log(full_greeting + name); | |
} | |
return greet_name; | |
} | |
var hello = greet('hello'); // builds a greeting function, prints nothing | |
hello('stephen'); // does the actual printing | |
var guttentag = greet('guttentag'); | |
guttentag('sarah'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment