Node JS, traditional data structures? (such as Set, etc), anything like Java.util for node? [closed]

I’m loving node JS and, coming from a Java background, am interested in even trying it out for some projects where node may seem a bit of a stretch, such as a search engine project.

One thing I’ve been a bit confused by is it seems JavaScript is lacking traditional data structures, for example a set, which has a precise definition extending even beyond computer science as it has been used in mathematics before computers existed (basically a list that doesn’t allow duplicates). It seems when using node JS there is no library like Java.util that has these basic data types that I have grown accustomed to, I realize I could create them myself but this just adds more overhead to the project.

Are there any libs for node (or JavaScript in general) that address this? I think node has a lot of potential to replace the use of a language like Java for a lot of projects as it has so many advantages in terms of development speed, but having to recreate data structures that are taken for granted in a more mature platform could be too much overhead for a small project.

I apologize if there are other questions like this, however I spent some time searching and didn’t come up with much.

Collections.js has Lists, Maps, Queues, Sets, and Heaps, all with consistent interfaces. Github.

it seems JavaScript is lacking traditional data structures…

Yes, this is javascript, the very concept and implementation of data structure is done quite differently from languages like Java.

Read More:   How to set ChartJS Y axis title?

I’m not sure that you’re really going to find what you’re looking for with Javascript. Howver, there are some libraries like underscore that should make it easier to build the type of structures that you want.

Its no longer true that node.js doesn’t have Set and Map objects among other things. node.js has had them since at latest v12.

But of course, if you want libraries like java has, check npm or github. You’re not limited to what comes standard in node.js.

Have you looked into Underscore.js?

It’s not a one to one with java.util but it provides a bunch of commonly needed utility functions.

As a lighter and faster alternative to Underscore.js, Lo-Dash ( is getting traction those days… But this is not Java.util! 🙂

Have a look at this one:

I think it fits what you are looking for.


A javascript standard data structure library which benchmark against C++ STL.

This library has strict time complexity guarantee and can be used with confidence.

The latest beta version includes iterator functions which can be used like iterator in c++.

Included data structures

  • Vector
  • Stack
  • Queue
  • LinkList
  • Deque
  • PriorityQueue
  • Set (using RBTree)
  • Map (using RBTree)
  • HashSet (for reference only)
  • HashMap (for reference only)


To help you have a better use, we provide this API document.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts