JavaScript Algorithms: Data Structures Explained in Code You Can Test
Most algorithm guides stop at pseudocode. trekhleb/javascript-algorithms gives you working JavaScript, a plain-language explanation, and tests for each topic. Started by Oleksii Trekhleb in 2018, the MIT-licensed repo has passed 196,000 stars and nearly 31,000 forks on GitHub.
What it is
The project is a study library of classic computer science written in JavaScript. Every data structure and algorithm sits in its own folder with a dedicated README that explains the idea and links to further reading, often including YouTube videos. The main README is translated into more than a dozen languages, including Portuguese, Spanish, Chinese, and Ukrainian.
Key features
- Broad coverage. Linked lists, heaps, tries, AVL and red-black trees, segment and Fenwick trees, graphs, and disjoint sets, plus algorithms for math, sets, strings, searching, sorting, graphs, cryptography, and even basic machine learning such as k-NN and k-Means.
- Beginner and advanced tags. Each entry is marked
BorA, so you can pick a starting point that fits your level. - Organized by paradigm. A second index groups algorithms by approach: brute force, greedy, divide and conquer, dynamic programming, backtracking, and branch and bound.
- Tested code. Implementations come with Jest tests, ESLint checks, and CI on GitHub Actions, with coverage tracked on Codecov.
- Big O cheat sheets. Tables compare the time and space complexity of common data structures and sorting algorithms.
Why it matters
If you live in the browser or Node.js, this is algorithm study in the language you already use every day. It works as interview prep, a refresher before tackling a performance problem, or a companion to a CS course. Because every example ships with tests, you can change the code and see right away whether you broke it.
Getting started
Clone the repo and run npm install. Then npm test runs the whole suite, or npm test -- 'LinkedList' runs a single topic. There is also a playground file at src/playground/playground.js where you can write your own solutions and test them with npm test -- 'playground'. For visual learners, the author's YouTube playlist and data structure sketches walk through the same material.
View the repo on GitHub: github.com/trekhleb/javascript-algorithms
Data Structures and Algorithms on YouTube | Data Structure Sketches

