找出链式队列里的 bug

来自 数组与链表
Node 24 进阶 6分钟 找出 2处问题

找出这个生成的链式队列中的边界错误。

JavaScript
class Queue {
  constructor() {
    this.head = null;
    this.tail = null;
    this.size = 0;
  }
  enqueue(value) {
    const node = { value, next: null };
    if (this.tail) this.tail.next = node;
    else this.head = node;
    this.tail = node;
    this.size += 1;
  }
  dequeue() {
    const value = this.head.value;
    this.head = this.head.next;
    this.size -= 1;
    return value;
  }
}
在试验场中打开
报告错误