title: NodeJS: can't access function parameter inside try/catch if use await
body: <p>I test this code on either nodejs 8 (without babel) &amp; babel, and both of them show same effects.</p>
  
  <pre><code>async function refreshBalance({ user }) {
    console.log(user) // show correct variable
    try {
      console.log(user) // throw error: variable not defined
      const user = await findObject('_User', user.id, {
        sessionToken: user.getSessionToken(),
      })
  
      return {
        balance: user.get('balance'),
        balanceUpdatedAt: user.get('updatedAt'),
      }
    }
    catch (error) {
      return formattedError(error)
    }
  }
  </code></pre>
  
  <p>but it doesn't throw error if I remove <code>await</code> like this:</p>
  
  <pre><code>async function refreshBalance({ user }) {
    console.log(user) // show correct variable
    try {
      console.log(user) // show correct variable, no error
  
      return true
    }
    catch (error) {
      return formattedError(error)
    }
  }
  </code></pre>
  
  <p>I know I can cache variable like this to make it work:</p>
  
  <pre><code>async function refreshBalance({ user }) {
    const theUser = user
    try {
      console.log(theUser) // `theUser` variable is safe, `user` variable will throw error
      const user = await findObject('_User', theUser.id, {
        sessionToken: user.getSessionToken(),
      })
  
      return {
        balance: theUser.get('balance'),
        balanceUpdatedAt: theUser.get('updatedAt'),
      }
    }
    catch (error) {
      return formattedError(error)
    }
  }
  </code></pre>
  
  <p>I'm curious why first approach show an error? I already search google &amp; didn't find any answer.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It throws an error if <code>user</code> is an object, and it didn't throw an error if <code>user</code> is either string or number.</p>
  
  <p>Here is how I execute the function:
  <code>refreshBalance({ user: { id: '123 '} })</code></p>