DEV Community

Cover image for Let's code a Queue as a linked list (in a nutshell)
crayoncode
crayoncode

Posted on

Let's code a Queue as a linked list (in a nutshell)

The shift() method of the Array type in JavaScript is quite an expensive operation, because by removing the first element of an array it needs to reassign all other indexes. If you need to make intensive use of shift(), it's worth considering implementing a queue based on a linked list, which is, what we're going to do today.

I hope you enjoy this little tutorial about implementing a Queue. Any feedback will be appreciated, just let me know and leave a comment. 🙏

Top comments (2)

Collapse
 
codefinity profile image
Manav Misra

Nice to see a 'semi-practical' application of linked lists in JS outside of silly code challenge and algorithm problems.

Collapse
 
crayoncode profile image
crayoncode

Thank you, I'm glad you appreciate the 'semi-practical' approach 😅

Some comments may only be visible to logged-in visitors. Sign in to view all comments.