shift() {
    if (!this.head) {
      throw Error('Nothing to shift')
    }

    const current = this.head

    if (this.length === 1) {
      this.head = null
      this.tail = null
    } else {
      this.head = current.next
      this.head.prev = null
      current.next = null
    }

    this.length--
    return current
  }
// Remove a node from the beginning
Remove a node from the beginning
Remove a node from the beginning
shift() {
    if (!this.head) {
      throw Error('Nothing to shift')
    }
    const current = this.head
    if (this.length === 1) {
      this.head = null
      this.tail = null
    } else {
      this.head = current.next
      this.head.prev = null
      current.next = null
    }
    this.length--
    return current
  }
shift ( ) { if ( ! this . head ) { throw Error ( 'Nothing to shift' ) } const current = this . head if ( this . length === 1 ) { this . head = null this . tail = null } else { this . head = current . next this . head . prev = null current . next = null } this . length -- return current }
Remove a node from the beginning
Remove a node from the beginning