DEV Community

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

Posted on

2 4

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.

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay