Normal traversal
This is head to tail movement of the pointer in a list. The normal traversal is done as:
- Create a pointer named curr as the current pointer.
- Assign the value of the head to the curr pointer.
- Move the curr pointer till the end and display output.
- curr => curr.next
Example:
Javascript
// To traverse and display the list display() { // Check if the List is empty if (! this .isEmpty()) { // traverse the list using new current pointer let curr = this .head; console.log( "Required list is" ); while (curr !== null ) { // Display element console.log(curr.data); // Shift the current pointer curr = curr.next; } } } |
How to traverse Doubly Linked List in JavaScript?
This article will demonstrate the Doubly Linked List Traversal using JavaScript. Traversal refers to the steps or movement of the pointer to access any element of the list.