Here, the shift method is created to remove the first element of the Linked List.
shift
class Node { constructor(data) { this.data = data this.next = null } } class LinkedList { constructor(head) { this.head = head } shift = () => { this.head = this.head.next } }
Last updated 2 years ago
Was this helpful?