Created
January 22, 2015 04:06
-
-
Save dlmanning/1605555460449fc9fc7c to your computer and use it in GitHub Desktop.
The mysterious case of the vanishing outer closure
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
zip(); | |
zap(); | |
zoom(); | |
function zip () { | |
var a = 1; | |
(function () { | |
// v8 will remove the outer closure | |
debugger; | |
})(); | |
} | |
function zap () { | |
var a = 1; | |
(function () { | |
eval('console.log("Hi mom!")'); // disable v8 optimizations | |
debugger; | |
})() | |
} | |
function zoom () { | |
var a = 1; | |
(function () { | |
// using a keeps the outer closure | |
var b = a + 1; | |
debugger; | |
})() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment