Singly Linked List (Implementation)
Explore how to create and manipulate a singly linked list in JavaScript. Understand node construction, adding nodes to the tail, inserting after a specific node, and removing nodes while managing list properties like head, tail, and length.
We'll cover the following...
In a singly linked list, we should be able to find, remove, and insert nodes. Before we can make a list, we first need to create the nodes.
We now created a constructor function that we can use each time we create a new node. By default, the new node’s next value is null, and its data is equal to the data we pass as an argument.
The linked list will be a class. This class will have several properties, such as the remove function, add function, and find function. However, before we can do any of that, we need to create its constructor.
By default, the list doesn’t have any nodes, and the length is equal to 0. If the list doesn’t have any nodes, both the head ...