JavaScript, as a very versatile language, made its way through the different stages of development. Originally conceived as a way to enable more dynamic behavior in the browser, it has conquered not only the complex field of developing, almost thick with client-like applications using the browser as the platform and runtime, but it is now also seen in server-side applications most prominently using Node.js.
Going all the way from making a document look more interactive by incorporating effects, to rendering a whole application on the client side is a wide spectrum of complexity and applications. Some may warrant an approach with a larger focus on application-design, some might best be served by smaller script-like approaches keeping the logic simple and local for the best maintenance.