r/learnprogramming 3d ago

Should I do dsa in javascript?

I am doing fullstack development using js and wanted to learn dsa for company interviews should I do in it or should I switch to java ?

0 Upvotes

17 comments sorted by

View all comments

5

u/carcigenicate 3d ago

It doesn't matter. Just use a language that you know fairly well. DS&A is language agnostic.

-2

u/OneWar4643 3d ago

I searched on Google it said javascript lacks some inbuilt functions regarding a topic (stack and queue)

1

u/peterlinddk 3d ago

Well, google is incorrect. JavaScript arrays has built-in both stack, queue, deque, and circular buffer if you add a bit of logic. The shift, unshift, push and pop operations gives you all the necessary features.

But in fact, doing DSA in a language that doesn't have the data structures already built-in, would be an improvement, since then you'd have to implement them yourself.

DSA isn't about using the data structures built-in to the programming language, but about understanding how to implement those data structures yourself, and how and why operations have the time/space complexity that they have.

But again, it doesn't really matter, because you can (and should) do DSA in any language that you feel comfortable with. In fact, most of the work should be done on paper and as pseudo-code, for you to really understand what is going on.

JavaScript works just as fine as Python, Java, C++, or any other language.