Computer >> Computer tutorials >  >> Programming >> Javascript

Doubly linked lists in Javascript


Doubly linked lists are almost the same as a singly linked list in all operations, we just need to keep track of one extra link per node. In singly linked lists, we just had next links, in doubly linked lists, we have 2 links, next and prev.

Doubly linked lists are represented as −

Doubly linked lists in Javascript

Note that in the class itself, we also need to keep track of the tail(last element).