Examples
In a standard, monolithic, application we mainly use JS to add extra functionality to applications, this varies from adding modal windows, interactive modules or slideshows to more radical things like searching a page, or dynamically loading other parts of the page. Data real-time loading has the biggest advantage of faster loading times.
Headless
For a decoupled application, where we view the frontend (the visible/usable part of the website) as a separate application, we also use JavaScript. The result is a single page application, which loads and interacts quickly. A much better user experience is the result. Working headless in some projects also has advantages for marketing teams.
Flexible
Javascript is a programming language that allows for different ways of programming; event-driven, functional, object-oriented or imperative. This flexibility allows the developer to use his favourite way of programming.
Fullstack
Javascript is usually used in the end user's browser to provide functionality there, but since 2009 there has also been Node.js. In this form, JS can also be used to work on the server, making Javascript a full-stack language.
Node.js is often used to realise real-time or asynchronous parts of a website. This fits perfectly into the microservice architecture, which lets programming languages do what they are good at and create small, individual modules with specific functionality. Easy maintainability and reliability are the logical advantages.