Open-source project
trekhleb/javascript-algorithms avatar
trekhleb/javascript-algorithms

trekhleb/javascript-algorithms: a version 0.0.4 manifest, a B or A label, and nineteen readme copies

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

196,841 stars31,023 forksJavaScriptMIT

At a glance

What is it?
A reading repository of JavaScript algorithm and data structure examples, each with its own readme and a difficulty label. The tooling tells you exactly what it checks, and the parts it does not check are the parts that rot.
Who is it for?
Use trekhleb/javascript-algorithms when you want to read a short, self-contained implementation of a named algorithm and then follow the readme next to it, because that pairing is what the repository is built around. Do not use it as a library, and do not read its difficulty labels as a curriculum: the manifest version 0.0.4 with no GitHub releases means there is no artifact to pin, and B or A is the only metadata an entry carries.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 66 days ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Version 0.0.4 with no releases, and a main entry the root does not contain

The manifest names the package javascript-algorithms-and-data-structures at version 0.0.4, MIT licensed, authored by Oleksii Trekhleb, with the repository url, a bugs url pointing at the issues tracker, and a homepage that resolves to the repository readme. Its main field points at index.js, while the top-level entries of the tree are .babelrc, .editorconfig, .eslintrc, .github/, .gitignore, .husky/, .nvmrc, BACKERS.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE, the localized readme files, assets/, jest.config.js, package-lock.json, package.json, and src/. index.js is not among them, and the repository has no GitHub releases. Consequence for the reader: the version field is not a release record, and this is a repository you read rather than a package you depend on. Anyone who installs it and imports from main is relying on a path the tree does not show at its root.

Node 22 and npm 10 are floors, and lint only reaches src

The engines field requires node >=22.0.0 and npm >=10.0.0, and an .nvmrc sits at the root next to it. The lint script is scoped to one path, and the dev dependencies behind it are eslint 8 with the airbnb config, the import, jest, and jsx-a11y plugins, alongside babel presets, jest 30, husky, and pngjs.

code
eslint ./src/**

Consequence for the reader: a contributor on an older Node is outside the stated range before any code is written, and because lint stops at src, the parts of the tree that get copied most often, such as the readme files and the configuration, are covered by nothing the manifest declares. Style in this repository is airbnb rules on one directory, and .editorconfig and .babelrc cover the rest of the setup without being part of the lint run.

One ci script chains lint to coverage, and prepare installs a git hook

Five scripts carry all the automation. There is a test script, a coverage script that reuses the test run with a flag, a ci script that runs lint and then coverage in one line, and a prepare script whose body is husky, with a .husky directory in the tree.

code
npm run test -- --coverage
code
npm run lint && npm run coverage

Consequence for the reader: coverage here is the jest run instrumented rather than a separate tool, so the percentage belongs to the same tests that pass. And because prepare runs husky, installing dependencies wires a git hook into your clone, which is a local change to your repository you did not ask for and that a contributor deciding whether to install has to know about. The continuous integration badge at the top of the readme tracks the master branch workflow, not a tagged release.

Every entry is labelled B or A and carries nothing else

Difficulty is one character per line. B means beginner and A means advanced, and the data structures section carries eight B entries, from linked list through priority queue, and eleven A entries, from trie through LRU cache, counting the five tree implementations nested under Tree. The page also says to pay more attention to why you are choosing a data structure than to how it is implemented, and to remember that each one has its own trade-offs. Consequence for the reader: the label is the only metadata an entry gets, and the page sets no criterion for assigning it, so an A entry can be material you already know and a B entry can be the one that costs you an afternoon. The stated priority is the decision, while the deliverable is an implementation, and the repository does not put the trade-offs in one place you can compare across structures.

The folder tree is the table of contents, and related trees share a parent

Navigation is by directory. Data structures live under src/data-structures with one folder each, and the tree implementations are grouped inside src/data-structures/tree, where binary search tree, AVL tree, red-black tree, segment tree, and Fenwick tree sit side by side. Algorithms are grouped by topic instead, with paths such as src/algorithms/math/bits, src/algorithms/sets/cartesian-product, and src/algorithms/string/hamming-distance. Each algorithm and data structure has its own separate readme carrying the explanation and links for further reading, including ones to YouTube videos. Consequence for the reader: the root readme is only an index, and the substance sits one directory deeper, so the taxonomy is fixed by folders that already exist. A structure that does not fit a grouping means inventing one, and a reader who finds an empty or absent folder learns nothing about why.

Eighteen translated indexes, and no script that keeps them in step

The root holds README.md plus eighteen localized copies, covering Simplified and Traditional Chinese, Korean, Japanese, Polish, French, Spanish, Brazilian Portuguese, Russian, Turkish, Italian, Indonesian, Ukrainian, Arabic, Vietnamese, German, Uzbek, and Hebrew. Every one of them is a full index rather than a stub, while the automation declared in the manifest is limited to lint, test, coverage, ci, and prepare. Consequence for the reader: there is no generator here, so a new algorithm has to be added by hand to the English index and to any translation the maintainer chooses to update, and the copies drift apart on their own. A reader who lands on a translated index can be looking at a list that no longer matches what is in src/, with nothing in the tree flagging the gap.

The readme opens with a war appeal, and the keywords say interview prep

The first block of the readme is an appeal about Ukraine being attacked, with links to three donation routes, the Serhiy Prytula Charity Foundation, the Come Back Alive Charity Foundation, and the National Bank of Ukraine. Only below that come the continuous integration and codecov badges and the sentence describing the repository as JavaScript based examples of many popular algorithms and data structures. The manifest keywords say the same kind of thing in list form, including interview and interview-preparation alongside sorting-algorithms, graph, and tree. The repository is not archived, the last push is dated 2026-07-26, and there are no GitHub releases. Consequence for the reader: the front page states an intent, interview preparation, rather than a library contract, and if you mirror or vendor that readme you inherit the appeal along with the index. The only maintenance signal available is that single push date, since there is no release history to compare it against.

Editorial conclusion

Use trekhleb/javascript-algorithms when you want to read a short, self-contained implementation of a named algorithm and then follow the readme next to it, because that pairing is what the repository is built around. Do not use it as a library, and do not read its difficulty labels as a curriculum: the manifest version 0.0.4 with no GitHub releases means there is no artifact to pin, and B or A is the only metadata an entry carries. Before you rely on anything here, check three things yourself: that the topic you need is actually in the tree, since the folder layout is the table of contents and an absent folder means an absent example; that the entry has been touched recently, since the last push is dated 2026-07-26 and nothing in the tree records per-entry freshness; and that you are on Node 22 or newer with npm 10 or newer, which the manifest states as a hard floor rather than a suggestion.

Frequently asked questions

What are algorithms in JavaScript?

In trekhleb/javascript-algorithms they are working examples rather than theory: the repository holds JavaScript based examples of many popular algorithms and data structures, and defines an algorithm as an unambiguous specification of how to solve a class of problems, a set of rules that precisely define a sequence of operations.

What is an algorithm in simple terms?

The readme's own wording is that an algorithm is an unambiguous specification of how to solve a class of problems. It pairs that with the warning that each data structure has its own trade-offs, which is why it tells you to think about why you choose one before how it is implemented.

what is javascript algorithms and data structures

It is a collection of JavaScript based examples of many popular algorithms and data structures, split into a data structures section and an algorithms section organised by topic such as math, sets, and strings. Each entry is rated B for beginner or A for advanced and has its own separate readme.

javascript algorithms and data structures github

The repository is trekhleb/javascript-algorithms, MIT licensed, with the implementations under src/ and one folder per topic. Its manifest declares jest as the test runner and a lint script that reaches only the src directory, with coverage produced by rerunning the tests with a coverage flag.

Is algorithms the hardest CS class?

The readme says nothing about course difficulty. What it does state is a per-entry label, B for beginner and A for advanced, along with the advice that you should pay more attention to why you are choosing a data structure than to how to implement it.

Official sources

  1. Official README
  2. Project repository