-
-
Save iam-peekay/79cc7a97faf67595d5871819a9747269 to your computer and use it in GitHub Desktop.
This file contains 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
var x = 10; | |
function foo(a) { | |
var b = 20; | |
function bar(c) { | |
var d = 30; | |
return boop(x + a + b + c + d); | |
} | |
function boop(e) { | |
return e * -1; | |
} | |
return bar; | |
} | |
var moar = foo(5); // Closure | |
/* | |
The function below executes the function bar which was returned | |
when we executed the function foo in the line above. The function bar | |
invokes boop, at which point bar gets suspended and boop gets push | |
onto the top of the call stack (see the screenshot below) | |
*/ | |
moar(15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment