

Personal opinion. JavaScript is a weird language. You can make non-web applications, but thats not the main use case so the road can be bumpy.
Almost any general language can be used for anything, including web stuff. But the language design will heavily influence how hard to achive the same thing.
If you are a beginner, focusing one one language is a good start, but learning another, then another is the best path you can take. So you can choose the right tool for the job.
I would advised to learn a strongly typed language, it seems harder at first, but type-checking makes your life way easier. (So if you stay on the javascript route, use typescript)
My usual advice for beginners is python with strict types. It is as generic as it gets, easy to pick up, and has a ton of library and stong communities.
Ignore stuff like Rust and new fancy languages for now. (Even tho my favorite language is Rust) I think learning C is a prerequisite for Rust or at least a deep understanding how the computer works.

My current favorite language is Rust. But I would never advice beginners to start with. Rust requires a deep understanding how memory works. Without the knowledge it is just fighting the borrow checker, which can be fustrating for beginners. For the same reason I would never advocate for Java: it is pretty hard to write java without understanding the oop paradigm.