Last updated: August 27, 2026.
JavaScript adds behavior to web pages and also runs in servers and command-line tools. In a browser it can respond to events, update the DOM, validate input, and request data.
const button = document.querySelector("#show-time");
const output = document.querySelector("#output");
button.addEventListener("click", () => {
output.textContent = new Date().toLocaleTimeString();
});| Task | API |
|---|---|
| Respond to users | Events |
| Change content | DOM |
| Load data | fetch() |
| Validate forms | Constraint Validation API |
Validate important rules again on the server because browser code and requests can be altered.