'Enqueue method not acting how it should

I'm looking at Colt Steele's enqueue method from his udemy class. When I create a new queue based on his code and console.log it, it shows that the the first property is continuously being updated, but by the code, it seems like it should only get updated when first equals null. So shouldn't it only get updated once?

Then, the last property's next property is updated to newNode, but after that, the last property is then updated to newNode, so wouldn't that cancel out the previous command? Wouldn't it add a new Node to the last's next property, and wouldn't that next property get reassigned to null by the next command when we then make the last property equal to the newNode?

function Queue(){
this.first = null;
this.last = null;
this.size = 0;
}

function Node(value){
  this.value = value;
  this.next = null;
}

Queue.prototype.enqueue = function(value){
  let newNode = new Node(value);
  if(!this.first){
    this.first = newNode;
    this.last = newNode;
  }
  else {
    this.last.next = newNode;
    this.last = newNode;
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source