Created
August 14, 2013 20:08
-
-
Save pbojinov/6235046 to your computer and use it in GitHub Desktop.
Revealing Module - http://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript
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 myRevealingModule = function () { | |
| var privateCounter = 0; | |
| function privateFunction() { | |
| privateCounter++; | |
| } | |
| function publicFunction() { | |
| publicIncrement(); | |
| } | |
| function publicIncrement() { | |
| privateFunction(); | |
| } | |
| function publicGetCount(){ | |
| return privateCounter; | |
| } | |
| // Reveal public pointers to | |
| // private functions and properties | |
| return { | |
| start: publicFunction, | |
| increment: publicIncrement, | |
| count: publicGetCount | |
| }; | |
| }(); | |
| myRevealingModule.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment