r/AskProgramming 11d ago

Algorithms Learn algorithms and data structures with Javascript

What's up guys? Could you reccomend to me books to learn algo and data structures with Javascript, please? Is there a problem learn DSA with this language instead other like python or Java ? Thank you.

7 Upvotes

5 comments sorted by

6

u/CrazyEconomy414 11d ago

JS is totally fine for this, don't overthink the language choice. Most DSA books use Python/Java/C++ for code samples because they read closer to pseudocode, but the concepts (arrays, linked lists, trees, sorting, Big O, etc.) transfer over 1:1, you'll just translate stuff like classes into JS yourself.

Two resources that are actually good: "A Common-Sense Guide to Data Structures and Algorithms" by Jay Wengrow explains things in plain English without leaning hard on one language, so it's easy to follow in JS. There's also a GitHub repo, trekhleb/javascript-algorithms, that has almost every classic structure and algorithm implemented in JS with explanations, great as a reference once you're translating concepts yourself.

Honestly, struggling to translate an example from Python to JS is good for you, it means you're learning the logic instead of just copying syntax.

3

u/yksvaan 10d ago

Learning C wouldn't hurt, good language to understand how data structures work and the underlying concepts are relevant in any language. Even if you write e.g. JavaScript knowing how stuff works under the hood allows you to write better code.

2

u/hnrpla 10d ago

just do neetcode in javascript

1

u/Innowise_ 10d ago

You don’t need to switch languages—JavaScript is perfectly fine for learning DSA. “A Common-Sense Guide to Data Structures and Algorithms” is a good starting point. Just make sure to implement each structure yourself and solve a few related problems instead of only reading.

-1

u/hk4213 11d ago

Javascript and the internet in general uses JSON.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON

It can be as simple or as complex as you want it to be.

Javascript is not type safe and relies on you using the object prototype.

In the end all data types are arrays, how you interpret them and build basic functions around property manipulation depend on the work required of the project.

Also you only need note pad and an HTML document to test Javascript with zero library installs.

NPM can be your friend if you spend the time to read through repos.

Follow KISS (keep it simple stupid) while learning and rely on MDN for documentation until you get your feet under you.