Created
September 18, 2019 17:31
-
-
Save xiaoyunyang/3d0e0027602980f4dc9d22b8c076ebe2 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 foo() { | |
let res = '' | |
let j = 10 | |
for(let i=0; i<j; i++) { | |
// uncommenting ... the following line causes error | |
// var j = 5 | |
res += `${j}, ` | |
j -= 1 | |
} | |
res += `${j}` | |
console.log(`foo: ${res}`) | |
} | |
function bar() { | |
let res = '' | |
let j = 10 | |
for(let i=0; i<j; i++) { | |
let j = 5 | |
res += `${j}, ` | |
j -= 1 | |
} | |
res += `${j}` | |
console.log(`bar: ${res}`) | |
} | |
function baz() { | |
let res = '' | |
var j = 10 | |
for(let i=0; i<j; i++) { | |
var j = 5 | |
res += `${j}, ` | |
j -= 1 | |
} | |
res += `${j}` | |
console.log(`baz: ${res}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment