javascript-algorithms: A Comprehensive Guide to Data Structures and Algorithms
This repository profile is provided by osrepos.com, an open source repository discovery platform.
Summary
The `javascript-algorithms` repository by trekhleb offers a vast collection of algorithms and data structures implemented in JavaScript. Each example comes with clear explanations and links for further reading, making it an invaluable resource for learning and interview preparation. It covers a wide range of topics, from fundamental data structures to advanced algorithmic paradigms.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
The trekhleb/javascript-algorithms repository is an exceptional resource for anyone looking to master algorithms and data structures using JavaScript. Maintained by trekhleb, this project has garnered significant attention, boasting 195143 stars and 31090 forks, highlighting its popularity and utility within the developer community.
It provides a comprehensive collection of algorithms and data structures, each meticulously implemented in JavaScript. What sets this repository apart are the detailed explanations accompanying each example, along with links to further readings and even YouTube videos, making complex concepts accessible to learners of all levels. Whether you are preparing for technical interviews, deepening your computer science knowledge, or simply exploring efficient problem-solving techniques, this repository serves as an invaluable guide.
Installation
To get started with javascript-algorithms, you'll need Node.js and npm installed. Once you have them, you can clone the repository and install its dependencies:
git clone https://github.com/trekhleb/javascript-algorithms.git
cd javascript-algorithms
npm install
You can also run ESLint to check code quality:
npm run lint
To execute all tests:
npm test
Or run specific tests by name:
npm test -- 'LinkedList'
There's also a playground for experimentation:
npm test -- 'playground'
Examples
The repository is structured to provide clear examples across various categories of data structures and algorithms.
Data Structures: It covers fundamental structures like:
Algorithms: Algorithms are categorized by topic and paradigm, including:
- Sorting: Bubble Sort, Merge Sort, Quicksort
- Searching: Linear Search, Binary Search
- Graph Algorithms: Dijkstra Algorithm, Breadth-First Search (BFS)
- Dynamic Programming: Examples like Fibonacci Number, Longest Common Subsequence
- Mathematical: Factorial, Euclidean Algorithm
Each entry includes its own README with detailed explanations, complexity analysis (Big O notation), and often links to external resources like YouTube videos for deeper understanding.
Why Use javascript-algorithms?
This repository stands out as a premier resource for several reasons:
- Comprehensive Coverage: It offers a vast array of both fundamental and advanced data structures and algorithms, making it suitable for various learning stages.
- Clear Explanations: Each algorithm and data structure comes with its own
READMEfile, providing detailed explanations, usage examples, and often links to further reading and video tutorials. - Practical JavaScript Implementations: All concepts are implemented in JavaScript, making it highly relevant for web developers and those working with JavaScript environments.
- Interview Preparation: It's an excellent tool for preparing for technical interviews, allowing users to practice and understand common algorithmic problems.
- Educational Tool: The inclusion of Big O notation explanations and complexity tables for data structure operations and sorting algorithms provides valuable theoretical insights alongside practical code.
- Active Community: With a large number of stars and forks, it indicates an active and well-regarded project within the open-source community.
Links
- GitHub Repository: https://github.com/trekhleb/javascript-algorithms
- Creator's Website: https://trekhleb.dev (for more projects and articles by the creator)
- Big O Cheat Sheet: http://bigocheatsheet.com/ (referenced in the repository for complexity analysis)
- Data Structures and Algorithms on YouTube: https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8 (linked in the repository's README)
Related repositories
Similar repositories that may be relevant next.

Loop Engineering: Orchestrating AI Agents with Practical Patterns and Tools
June 25, 2026
Loop Engineering is a GitHub repository offering practical patterns, starters, and CLI tools for building robust AI coding agent systems. It shifts the focus from individual prompt crafting to designing control systems that orchestrate agents over time. This project empowers developers to create autonomous, iterative AI workflows for various development tasks.
Pic Smaller: Intelligent Online Image Compression for Web and Mobile
June 20, 2026
Pic Smaller is an intuitive and powerful online tool designed for intelligently compressing various image formats, including JPEG, PNG, WEBP, AVIF, SVG, and GIF. It offers a user-friendly experience with automatic compression and customizable output options, all while ensuring complete safety through purely local processing without server-side logic.
My Virtual World: A Self-Hosted 3D AI Virtual World for Agent Harnesses
June 16, 2026
My Virtual World is an innovative self-hosted 3D AI virtual environment designed for agent harnesses such as OpenClaw and Hermes. It allows AI agents to live, work, move between buildings, and interact with objects in a persistent voxel-style world. This project offers a unique platform for developing and observing AI agent behaviors in a rich, customizable 3D setting.
Deliberation: Multi-Agent LLM Consensus for Code and Plan Review
June 15, 2026
Deliberation is an innovative GitHub repository that enables Claude Code to leverage multiple LLMs like GPT, Gemini, Grok, and 400+ OpenRouter models for expert second opinions and arbiter-mediated consensus. It provides specialized AI agents for tasks such as code review, security analysis, and architectural design, ensuring comprehensive and reliable feedback. This project helps developers get diverse perspectives and achieve higher quality in their work.
Source repository
Open the original repository on GitHub.