title: Does the Javascript Engine delete variables from scope if they are not used?
body: <p>I have a function called setupChannel that takes "socket" as a parameter. I am using redux-thunk so setupChannel returns an anonymous function with dispatch and getState as parameters. Inside that anonymous function, the debugger says socket is undefined unless I make specific reference of socket in the function.</p>
  
  <p>Here socket is <strong>undefined</strong> when I use the debugger:</p>
  
  <pre><code>export const setupChannel = socket =&gt; {
    return (dispatch, getState) =&gt; {
      debugger;
    }
  }
  </code></pre>
  
  <p>Here socket is defined when I console.log it</p>
  
  <pre><code>export const setupChannel = socket =&gt; {
    return (dispatch, getState) =&gt; {
      console.log(socket);
    }
  }
  </code></pre>
  
  <p>Socket is also defined when I simply call a method on it:</p>
  
  <pre><code>export const setupChannel = socket =&gt; {
    return (dispatch, getState) =&gt; {
      socket.connect();
    }
  }
  </code></pre>
  
  <p>So my question remains, why is it undefined when I pop the debugger in or possibly when I don't reference it?</p>