Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created July 29, 2015 05:53
Show Gist options
  • Select an option

  • Save dnasca/03c3969e994f5f03669f to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/03c3969e994f5f03669f to your computer and use it in GitHub Desktop.
Pattern: A function with scope
// 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