Created
July 22, 2016 00:26
-
-
Save Cheffheid/1372bff50181122fa1808935221f8c49 to your computer and use it in GitHub Desktop.
Basic Closure
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
function greeting( subject ) { | |
var message = "Hello %s!"; | |
// hello() will have access to the message variable in the greeting() scope. | |
function hello() { | |
return message.replace("%s", subject); | |
} | |
return hello(); | |
} | |
var world = greeting("World"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment