- A frontend language, which is included in HTML files, that adds interactivity to the website.
- A backend language, for writing web servers, in the form of Node.JS.
- Add or change CSS in an HTML document.
- Create new HTML elements programatically.
- Track what a user is doing, and react - i.e., do something when a user clicks.
- Change or delete HTML tags, i.e. change the classes an element has.
- Store data in objects and arrays.
On the backend, things are different. You can do things like:
- Create entire websites, and code what happens at certain URLs.
- Build servers that users can connect to.
- Build live APIs and Web Sockets that users can connect to.
- Handle compression of files for a faster experience.
- Manipulate data for storage in databases.
- Inline scripts, that sit within HTML documents.
- In a separate file, included in HTML documents via the script tag.
- Within HTML elements, using attributes.
In an inline script
In a separate file
In a an HTML tag
This is discouraged, but you may see something like this in HTML documents sometimes:
index.js, and run them from the command line. You can do this by navigating to the folder your file is in, and running the node command: