Created
July 18, 2012 18:33
-
-
Save lukehoban/3137947 to your computer and use it in GitHub Desktop.
const questions
This file contains hidden or 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
//#1 | |
// Current spec would suggest that this is an early error during compilation of the main code. | |
// However, dynamically, the "x=20" will write to the "var x" declared inside g. | |
// This is a case where the early error for assignments to const variables appears to overreach, flagging an error which will not actually occur if the code were allowed to run. | |
function f() { | |
const x = 5; | |
function g() { | |
eval(“var x = 10”); | |
x = 20; | |
} | |
} | |
//#3 | |
// It was suggested on es-discuss that this should be an early error during the 'eval'. | |
(function() { | |
eval("const x = 4"); | |
const x = 3; | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment