Forked from michaelficarra/es6-fd-block-scoping.js
Last active
December 6, 2015 21:26
-
-
Save bakkot/1a0ad520485265b1ef87 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 = ""; } | |
function y() { h = f; } | |
{ | |
// var-scoped f is undefined, let-scoped f is a function | |
f = 1; // let-scoped f gets value 1 | |
x(); // var-scoped f gets value "" | |
y(); // h gets value of var-scoped f | |
function f() {} // var-scoped f gets value of let-scoped f | |
g = f; // g gets value of let-scoped f | |
} | |
return [typeof f /* number */, typeof g /* number */, typeof h /* string */]; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment