Skip to content

Instantly share code, notes, and snippets.

@xiaoyunyang
Created September 18, 2019 17:31
Show Gist options
  • Save xiaoyunyang/3d0e0027602980f4dc9d22b8c076ebe2 to your computer and use it in GitHub Desktop.
Save xiaoyunyang/3d0e0027602980f4dc9d22b8c076ebe2 to your computer and use it in GitHub Desktop.
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