Skip to content

Instantly share code, notes, and snippets.

@lukehoban
Created July 18, 2012 18:33
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 lukehoban/3137947 to your computer and use it in GitHub Desktop.
Save lukehoban/3137947 to your computer and use it in GitHub Desktop.
const questions
//#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