Skip to content

Instantly share code, notes, and snippets.

@kselax
Created November 14, 2018 23:11
Show Gist options
  • Select an option

  • Save kselax/d7775192befcc1a256ccb9cbbf7b8335 to your computer and use it in GitHub Desktop.

Select an option

Save kselax/d7775192befcc1a256ccb9cbbf7b8335 to your computer and use it in GitHub Desktop.
priority let by var
{
var x = 1
{
let x = 2 // SyntaxError: Identifier 'x' has already been declared
{
function f(){
let x = 10
{
var x = 20 // SyntaxError: Identifier 'x' has already been declared
{
console.log('fscope3 x = ', x);
}
console.log('fscope2 x = ', x);
}
console.log('fscope1 x = ', x);
}
f()
console.log('scope1 x = ', x);
}
console.log('scope2 x = ', x);
}
console.log('scope3 x = ', x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment