DEV Community

Discussion on: JavaScript Data Structures: Doubly Linked List: Intro and Setup

Collapse
 
trueleroy profile image
TrueLeroy

i dont really see a use case for linked lists in a language like JS. In C/C++ you can't dynamically expand an array like you can in JS, so there is a use case there, but JS is more flexible and the cost of access is really high, so you're probably better off with JS alternatives like a simple array.

I'm curious what kind of use case exists for linked lists in JS :)

Collapse
 
jamiescript profile image
Jamiebones

When you want to insert n delete from the beginning of a large array; it will be better to make use of a linked list instead because insertion n deletion from the beginning happen in constant time O(1) as compare to arrays which is O(n)