Last active
December 15, 2015 10:59
-
-
Save justinobney/5250221 to your computer and use it in GitHub Desktop.
JS Closure Beginner 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 MyApp = MyApp || {}; | |
| (function(app) { | |
| var count = 0; | |
| app.add = add; | |
| app.getCount = getCount; | |
| function add() { | |
| count++; | |
| } | |
| function getCount() { | |
| console.log(count); | |
| } | |
| })(MyApp); | |
| MyApp.echoCount = function() { | |
| console.log(count); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment