Lists in JavaScript

Jaskomal
2 min readJul 12, 2021

Software is made up of 2 basic pieces, data and algorithms. Algorithms are what turn data into something a program can use. Data structures are how we store data and also retrieve that data, they are also the building blocks that help organize a program, a real world comparison would be an aisle of a store, in that aisle you will find similar types of items, in a data structure you will find similar data. One example of data structures are arrays and objects in JavaScript.

In this article we will be talking about Linked Lists. This data structure is useful when you need to manage how memory is set aside. Linked lists are a better option than arrays because they allow dynamic memory allocation vs arrays which are static memory allocation. Arrays use a fixed amount of memory when they are instantiated and have a cap on how much data you can add to that array.

But before we get to linked lists let’s go through some of the basics first, starting with Nodes. Nodes are the building blocks for may data structures including linked lists, queues, trees, and stacks. A node will contain any type of data, and a link to another node this link is called a pointer and when a pointer is null is when you know you have reached the end of the link path. Here is a visual, nodes are the numbered circles.

Linking a node to another node will create a singly linked list. We link these nodes together using their next property. This allows us to store data in a linear fashion.

--

--