JS is the most commonly used programming language
According to Stack Overflow Developer Survey 2021, JS gets the first programming language which commonly used in 9 years consecutively. Although that survey doesn't describe why most developers use JS, at least it informs us that JS has been used by survey participants.
In my opinion, the reason why JS has been commonly used is its easiness, clear documentation, broad development targets, and community support. It also has enormous open source contributors to create libraries or frameworks written with JS.
The Versatility Aspect of JS
When JS release for the first time, it was only used in the Netscape internet browser, then Internet Explorer (IE), Mozilla, Google Chrome, Opera, and other internet browsers follows. JS libraries and frameworks before the birth of Node.js like jQuery, angular js, etc have been used by front-end developers.
After the initial release of Node.js in 2009, it's possible to build a backend application written in JS. JS has additional developers who use libraries and frameworks for Node.js like express js, koa js, adonis js, hapi, restify, etc. The popular terms of full-stack development with JS like ME(A/R/V)N (MongoDB, Expressjs, Angular/ React/ Vue, Node.js) make developers able to create both frontend and backend applications with JS only.
Provide rich features for web
Let's imagine when we want to open an e-commerce website in the old days. Your device has to connect to the internet to access that website. You have also to open your email to check notifications on the website, and then back to the website again to follow up on the notification. You may be thinking to use the mobile app version of that e-commerce website which provides push notifications, safe payments, offline support, etc.
Now JS provides API to use an offline-first approach, so you can access it when your device is not connected to the internet*. It also provides an API to register push notifications in both foreground and background states. Even JS provides API to prioritize contents based on your network quality. There are also provide more features which you can see at whatwebcando.today. It seems like the web version of e-commerce is the same as the mobile app, right?
* Offline-first approach can be achieved if you previously access the website before and navigate to several pages in it.
- Stack Overflow Developer Survey 2021
- A Brief History of Node.js
- Articles inside web.dev like Progressive Web App and Adaptive Serving Based On Network Quality
- What Web Can Do Today?