title: Linked List Javascript, reassignment of variable breaks?
body: <p>Can someone explain why these two snippets of code are not equivalent? Why does the first one work whereas the second one does not? I just reassigned the variable name?</p>
  <pre><code>removeAt(index){
      let count=0;
      if(index &gt; 0 &amp;&amp; index &gt;this.size){
          return;
      }
      let current=this.head.next;
      if(index===0){
          this.head.next=this.head.next.next;
      }else{
          let previous;
          while(count&lt;index){
              count++;
              previous=current;
              current=current.next;
          }
          previous.next=current.next;
      }
  
  }
  </code></pre>
  <p>However, when I reassign this.head.next to current it does not work????</p>
  <pre><code>removeAt(index){
      let count=0;
      if(index &gt; 0 &amp;&amp; index &gt;this.size){
          return;
      }
      let current=this.head.next;
      if(index===0){
          current=current.next;
      }else{
          let previous;
          while(count&lt;index){
              count++;
              previous=current;
              current=current.next;
          }
          previous.next=current.next;
      }
  
  }
  </code></pre>