Skip to content

Instantly share code, notes, and snippets.

@domfarolino
Created September 23, 2016 20:16
Show Gist options
  • Save domfarolino/60ea2d2846425375581434bea12a40d8 to your computer and use it in GitHub Desktop.
Save domfarolino/60ea2d2846425375581434bea12a40d8 to your computer and use it in GitHub Desktop.
1st example explaining closures to Pat
var outerFunction = function(outerFunctionState) {
var innerFunction = function() {
console.log("Snapshot of the outerFunction's state is: " + outerFunctionState);
}
return innerFunction;
}
var generatedFunction1 = outerFunction(5);
var generatedFunction2 = outerFunction(10);
generatedFunction1();
generatedFunction2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment