Created
September 4, 2013 21:45
-
-
Save olov/6443290 to your computer and use it in GitHub Desktop.
es6 loop variable bindings
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
// will this example | |
let arr = []; | |
for (let x = 0; x < 5; x++) { | |
x++; | |
arr.push(function() { return x; }); | |
} | |
// ..be semantically equivalent to this? | |
let arr = []; | |
for (let x_ = 0; x_ < 5; x_++) { | |
let x = x_; | |
{ | |
x++; | |
arr.push(function() { return x; }); | |
} | |
x_ = x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes, that is a valid equivalence for this simple case. but there are some complicaiton. See the thread that starts with https://mail.mozilla.org/pipermail/es-discuss/2012-February/020272.html