Skip to content

Instantly share code, notes, and snippets.

@emacdona
Last active October 9, 2021 14:06
Show Gist options
  • Save emacdona/2d7a6beb80cd60a4713a358266dc80b8 to your computer and use it in GitHub Desktop.
Save emacdona/2d7a6beb80cd60a4713a358266dc80b8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
(function(){
function aFunction(){
var a = "A1";
let b = "B1";
console.log(`Inside function, BEFORE variable assignments in "inner" lexical scope:\n\t<a: ${a}, b: ${b}>`);
// Prints:
// Inside function, BEFORE variable assignments in "inner" lexical scope:
// <a: A1, b: B1>
{
var a = "A2";
let b = "B2";
console.log(`Inside "inner" lexical scope:\n\t<a: ${a}, b: ${b}>`);
// Prints:
// Inside "inner" lexical scope:
// <a: A2, b: B2>
}
console.log(`Inside function, AFTER variable assignments in "inner" lexical scope:\n\t<a: ${a}, b: ${b}>`);
// Prints:
// Inside function, AFTER variable assignments in "inner" lexical scope:
// <a: A2, b: B1>
}
aFunction();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment