Practice Alorithms in Typescript or Javascript?

Typescript makes things easier for me to reason about, I. Javascript may be more popular or perhaps the only option during an algorithm test.

My choice hinges on just how available Typescript is an an option during an algorithm test. What have you guys found to be the case?

Well, of course TS is a superset of JS so any TS developer should be comfortable in JS.

You say “algorithm test”. What do you mean by that?

Do you mean just logging onto a algorithm test site? I see that leetcode offers a TS option, I imagine others do too.

Do you mean an employment test? That depends. Some of the employment tests I have done have asked me what language I would want to use - the algorithm is usually the same regardless. Some have assumed I would be testing in JS because that is what they use. If you are looking for a job, I would recommend practicing both, just to be ready.

I have just started learning TS and like it a lot, but I think I’d still want to use JS in a timed test - less typing.

1 Like

Worrying about a specific language misses the point of algorithms. Algorithms are language agnostic.

How does TypeScript help you?

My personal choice would be Python or other language with a good standard library. A good standard library has useful data structures that are actually really useful for this type of tasks.

Between JS and TS, JavaScript is faster to type and there is no significant benefit of using TypeScript in a few lines of code. Just my 2 cents.

Typescript helps keep track of the shape of data. Also its explicit typings make it easy for the coder to think through the problem as he does annotations at a faster-than-jsdoc pace. I much prefer algo practice in Typescript if it’s an option.

Employment tests, yes.

It is true that there’s more typing but I think you’ll find it easier to keep track of what’s happening as well. Everything is out there in the open. const result will be of this shape. ok, time to map... Good luck with your studies :slight_smile:

If it’s an employment test they will tell you what to use. If you have language options in the test, just pick one. There is nothing to optimize here.

I guess that’s a matter of opinion. I agree that there’s some truth to that in a large app, but I’ve never had that problem in an algo challenge.

Again, I’d hop on some algo challenge sites and practice both to be ready for anything.


TypeScript may help you reason about by providing more context to what your doing, but you should do more or less just as fine with JavaScript during an interview with an algorithm.

Same could be said for whatever tooling/editor is available during a algorithm challenge during an interview. If you know the algorithm, and can solve bugs with the code that may pop up you should be OK, extra tooling or not.

1 Like