From the course: JavaScript: Building Linked Lists Data Structures
Unlock this course with a free trial
Join today to access over 25,400 courses taught by industry experts.
Deleting - JavaScript Tutorial
From the course: JavaScript: Building Linked Lists Data Structures
Deleting
- [Instructor] Welcome to the module on deleting nodes from the front and end of the doubly-linked list. In the last module, you learned about printing in the console, the list of data starting at the first node and the last node. In this module, you will learn how to delete the first node from your list and the last node from your list. So why would you want to delete specific nodes? Well, again, similar to clearing a list, let's say you only want to keep the data in between the first and last node. And delete the first and last nodes, you would want code that would allow the rest of your data to persist while only deleting specific data. Let's take a look at the code. So if we want to delete nodes from the front of the double-linked list, you will first want to check if the list is empty, and if it is, null will be returned. However, if it is not empty, then a variable will be declared with the label value and the assigned value will be this.head.value, which is the value of the…