Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active January 16, 2016 17:18
Show Gist options
  • Save michaelficarra/32602887d40d7b93deee to your computer and use it in GitHub Desktop.
Save michaelficarra/32602887d40d7b93deee to your computer and use it in GitHub Desktop.
(function () {
var g, h;
function x() { f = ""; /* var-scoped f gets value "" */ }
function y() { g = f; /* g gets value of var-scoped f */ }
{
/* var-scoped f is undefined, let-scoped f is a function */
h = f; /* h gets value of let-scoped f, a function */
f = 1; /* let-scoped f gets value 1 */
x();
y();
function f() {} /* var-scoped f gets value of let-scoped f, a number */
}
return [typeof f /* number */, typeof g /* string */, typeof h /* function */];
})();
@michaelficarra
Copy link
Author

You are completely right. I made a mistake, then checked my answer against Chakra, who's supposed to have done this correctly, and got the same answer. I've updated the example to be clearer (and hopefully right this time!), based on your fork. ❤️ Thanks, Kevin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment