Thursday, 1 June 2017

how can I access to a variable in try block in other try block?

http://blog.grossman.io/how-to-write-async-await-without-try-catch-blocks-in-javascript/ In this link, there are some codes that access to a variable in try catch but when I try this in my server It doesn't work because It's out of scope. how can I do this?

try {
  const foo = "bar"
} catch (e) {
  console.log(e)
}

try {
  console.log(foo) -> is not defined
} catch (e) {
  console.log(e)
}



via Phillip YS

No comments:

Post a Comment