title: Mutations of object passed to a function are not being applied
body: <p>I'm having some trouble figuring out why an object that I pass to another function is not being modified as expected.</p>
  <p>Suppose I have the below:</p>
  <pre><code>const doSomethingAsync = async ({ data }) =&gt;
      new Promise((resolve) =&gt; setTimeout(() =&gt; {
          data = { id: 5 };
  
          resolve();
      }, 1000));
  
  const mainFunc = async () =&gt; {
      let data = {};
  
      console.log('before', data); // prints {}
      await doSomethingAsync({ data });
      console.log('after', data); // prints {}
  }
  
  await mainFunc();
  </code></pre>
  <p>The variable <code>data</code> never gets changed.</p>
  <p>What's weird is that if I change,</p>
  <pre><code>let data = {};
  </code></pre>
  <p>to,</p>
  <pre><code>const response = {
      data: {},
  };
  </code></pre>
  <p>then it works just fine:</p>
  <pre><code>const doSomethingAsync = async ({ response }) =&gt; new Promise((resolve) =&gt; setTimeout(() =&gt; {
      response.data = { id: 5 };
  
      resolve();
  }, 1000));
  
  const mainFunc = async () =&gt; {
      const response = {
          data: {},
      };
  
      console.log('before', response.data); // prints {}
      await doSomethingAsync({ response });
      console.log('after', response.data); // prints { id: 5 }
  }
  
  await mainFunc();
  </code></pre>
  <p>I know objects are passed by reference, but that's exactly what I'm doing in the first example. What am I doing wrong here?</p>