Created
July 29, 2015 05:53
-
-
Save dnasca/03c3969e994f5f03669f to your computer and use it in GitHub Desktop.
Pattern: A function with scope
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
| // function with scope | |
| functionWithScope = (function (){ | |
| var x = 1; | |
| return function() { | |
| console.log('Private variable value: ' + x); | |
| }; | |
| }()); | |
| functionWithScope(); //output: 'Private variable value: 1' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment