1. Choose either JavaScript or Python as you see fit.
  2. If it’s hard to choose, learn JavaScript.

The Stack Overflow Developer Survey 2022 has a separate section that calculates the ranking of popular programming languages to learn. This ranking confirms that most developers are acting on learning JavaScript along with HTML and CSS, or choosing Python.

If you don’t want to compare JavaScript and Python, choose JavaScript. To see why, check out the frontend and backend developer roadmaps. JavaScript is a must-have programming language for the frontrunner and a useful knowledge for the backrunner. In addition, JavaScript is used for many backend tasks on par with Python, Java, PHP and other languages. If you start learning frontend and suddenly switch to backend development, your JavaScript knowledge will not go to waste.

Other benefits of JavaScript were listed by experts: a former techlead at Google from the TechLead channel and DappCamp founder Pritti Kasireddy from freeCodeCamp.org:

You can get a project up and running in a short time and share the results. These encourage more practice and build up a portfolio.
Quick feedback. You write code in the IDE, refresh your browser, and see results right away. Programming languages like Java or Haskell can’t do that – they require compilation and make it hard to learn.
Versatility. JavaScript works in any modern browser, device, and operating system. It can be used for many purposes: as a scripting language, to create web applications or server APIs, for bots and IOT-device applications, for desktop and mobile programs, and for virtual reality projects.
Tool availability. You can install any IDE and write code right away – no additional programs are needed. If you decided to program for iOS or Android, you would have to set up Xcode or Android Studio – this makes it difficult to get started.
Lots of jobs for aspiring and experienced developers.