Why are linked lists not used frequently in Javascript

Viewed 413

I’ve been working with JavaScript for around 4 years. In all the applications I’ve worked on, I’ve never once seen someone use a linked list. Why is that? Data structures are so prominently featured in most learn-to-program courses. Yet I almost never see them used in the real world.

1 Answers

This may not be the perfect explanation of this but I think will give you a fair idea about it.

  • The scenarios which will make sense to use Linked list on JavaScript are very rare. You have been working on JavaScript for 4 years when did you feel a need to use linked lists and not JavaScript Array

  • The main purpose of using linked list is performance improvements, when there a is a huge collection of records and frequent changes to them linked lists help in optimizing that. But that case may not be true for most of the JavaScript applications. Arrays are pretty much bale to do that for JavaScript.

  • Most of the frameworks rely on array's be it React, Vue etc.

  • In case of linked list methods like unshift, etc. are much faster. while methods on Arrays, such as push, run considerably faster than Linked Lists.

  • The use of linked list is justified when you need to make a lot of modifications to a huge list — especially when adding or removing items somewhere other than the end of the list and such cases are rare in JavaScript/front end.

  • Last but not the least JavaScript has great support for Arrays but you will have to code your own implementation or use some library that provides linked lists implementation.

Related