1. Code
  2. JavaScript

Data Structures With JavaScript: What's a Data Structure?

Read Time:3 minsLanguages:
This post is part of a series called Data Structures in JavaScript.
Data Structures With JavaScript: Stack and Queue
Final product imageFinal product imageFinal product image
What You'll Be Creating

What's a Data Structure?

I’ve always considered the term “data structure” to be confusing. What the heck is it? Is it data with structure, which is an equally ambiguous term? 

When I used to share my bewilderment with my peers, they would quickly quip, "data with structure". The look of satisfaction on their faces used to make me question myself. I guess that's all I needed to know.... 

Eventually, I learned to resolve the concept of a data structure with a simple rephrasing of the term "data structure" to "structure of data". In this context, the focus shifts from data (a thing) to structure (organization). This is a subtle but immensely important detail. We aren’t focusing, in other words, on things, but on the process of organizing things.

Let's imagine that the things we're discussing are books. What makes more sense: books with structure or organization of books? In my opinion, the latter is easier to comprehend. The focus is correctly on organization—not books. 

Different Types of Data Structures

Books, similar to data, can be organized in many ways. Let's image that we have 20 books. How do we organize them? 

If we want to quickly find a book when we need a reference to it, we can insert all of our books in alphabetical order on a shelf; every time we need a book, we can find it using our knowledge that books are stored alphabetically. 

If we want to read all of our books in a specific order, maybe from the first book we inserted into our collection to the last book we insert, then we would want to place our books in a sequence with that order; moreover, we want to impose a restriction of reading our books in only that order. 

If we lack the storage to keep all of our books in the same room, maybe we want to organize our books in a way where we can quickly find them. How about placing our 20 books throughout our house, and then creating a list with two columns: the first column lists a book's title; the second column lists a book's location. 

At this moment, it should become clear that there are many ways to organize books; moreover, there are many different types of data structures. The data structure we use in web development, just like our example with books, depends on our needs. 

Now that we understand that there are many types of data structures for different types of needs, we need to understand that we can utilize and create these data structures without an esoteric knowledge of coding. We all, even those without neckbeards, can create data structures. All we need is an understanding of everyday JavaScript—primitive types (e.g. Boolean) and reference types (e.g. Object).

If this seems hard to imagine, don't worry. I used to think of a Set, which is a type of a data structure, as just a Set! Oh, how naive, Cho. A Set isn't a thing; a Set is the name assigned to a particular way of organizing data. What's equally important, a Set is created using objects.  

The Goal

This series on Data Structures with JavaScript will reveal that data structures aren't meant to be opaque and mysterious. Rather, they are used to make our lives easier. I will try to reinforce this point with the introduction of one or two very similar data structures in each of the articles in this series. 


Since there are too many data structures to be adequately covered in this series, we will explore only a few but the most common data structures: 

  • Stack and Queue
  • Singly-Linked List and Doubly-Linked List
  • Tree (Depth-First Search and Breadth-First Search)


When we complete this series, I hope you'll not only learn how to implement these common data structures, but you'll also see that they are used all around us. When you realize that these data structures serve a very specific and useful purpose in organizing all data, you'll elevate your appreciation for them. You'll begin to think differently about your data and how you organize it, too.

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.