Skip to content

Instantly share code, notes, and snippets.

@lelouchB
Last active March 1, 2021 16:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lelouchB/3762e5870e4eace205379ffa3b72d9a7 to your computer and use it in GitHub Desktop.
Save lelouchB/3762e5870e4eace205379ffa3b72d9a7 to your computer and use it in GitHub Desktop.
var outerFunction = function () {
let variable1 = "Example of closure"
var innerFunction = function () {
console.log(variable1)
}
return innerFunction;
}
var newFunction = outerFunction()
newFunction()
//Example of closure
@doniseferi
Copy link

Hey great article on closures and lexical scoping. Update the return statement to return innerFunction and not nested function 😃

@lelouchB
Copy link
Author

lelouchB commented Aug 2, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment