Last active
January 16, 2016 17:18
-
-
Save michaelficarra/32602887d40d7b93deee to your computer and use it in GitHub Desktop.
This file contains 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
(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 */]; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.