Created
October 26, 2014 18:14
-
-
Save kzar/8b17b50b235e818d2826 to your computer and use it in GitHub Desktop.
JS 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 counter = (function () { | |
| var i = 0; | |
| return { | |
| view: function () { return i; }, | |
| next: function () { i += 1; } | |
| } | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment