Before JavaScript, to have dynamic content on a web page, you had to rely on 3rd party software that the user would have to have installed on their computer. These environments included programs like Java and Flash Player. But as JavaScript came on the scene these programs fell by the wayside. Now, there is a native language to use to have dynamic content on the web.
When you changed pages on this website, you did not navigate to a new page. Rather, the info for the new page was already loaded, and the JavaScript changed what was on the screen without moving to a new page. This makes the user experience far better. JavaScript can also do things like update prices live, like on a stock trading website, or to change the color of something on the user's command, or even for making a video game (updating graphics and reacting to the user's input).