Skip to content

Instantly share code, notes, and snippets.

@mosijava
Created July 27, 2018 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosijava/d9cee12c7f639faec8ef0490a80c2ca9 to your computer and use it in GitHub Desktop.
Save mosijava/d9cee12c7f639faec8ef0490a80c2ca9 to your computer and use it in GitHub Desktop.
an example of closures to show the function can't de-alocate after returning closure
function outerFunction(x) {
var z = 3;
return function (y) {
alert(x + y + z);
}
}
var innerFunction = outerFunction(2); // innerFunction is now a closures.
innerFunction(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment