Shift
Here, the shift
method is created to remove the first element of the Linked List.
class Node {
constructor(data) {
this.data = data
this.next = null
}
}
class LinkedList {
constructor(head) {
this.head = head
}
shift = () => {
this.head = this.head.next
}
}