DEV Community

Cover image for Linked List Data Structure Using Javascript
Nikhil Bobade
Nikhil Bobade

Posted on

Linked List Data Structure Using Javascript

Linked List

A Linked List is a linear data structure. The Linked List consisting of a group of nodes that together represent a sequence.

Linked List has behaved like each node contains a connection to another link or another node. also linked list is the most used data structure after the array.

Insert :

The insert method is used for adding the data to the LinkedList.

Delete :

The delete is deleting the given node or element from the linked list.

Search :

A search returns a given node on the linked list.

Null :

if the next element is not having a data or node then this condition was true and return null.

Alt Text

This is how a linked list works the 1st is head and after I go for the next node or data if he doesn't get the next data then return null.

LinkedList example using Javascript :

class LinkedListNode{
    constructor(data){ = data; = null;
        this.previous = null;

class LinkedList{
        this.head = null;
        this.tail = null;
        this.length = null;

        const node = new LinkedListNode(data);

            this.head = node;
            this.tail = node;
            this.tail.previous = node;
   = node;
            this.tail = node;

        this.length +=1;

const dataList = new LinkedList();


let currentNode = dataList.head;

for (let i = 0; i < dataList.length; i++) {
    currentNode =;

console.log(JSON.stringify(dataList, null , 2));

Enter fullscreen mode Exit fullscreen mode

Output :

Alt Text

I hope you like this also comments about your thoughts.

For more content follow me on Instagram @developer_nikhil27.

If you want to more support me then buy me a coffee.

Thank you.

Top comments (0)