Glossary term

JavaScript

JMore terms under J

JavaScript is a programming language that can make web pages respond to what people do. It can update information, react to a click or send a request without loading a whole new page.

A page can show a new message after a click without loading another document. Here is a small example:

JavaScript · update text after a click
<button type="button" id="show">Show message</button>
<p id="message"></p>
<script>
  document.querySelector("#show").addEventListener("click", () => {
    document.querySelector("#message").textContent = "Hello, web.";
  });
</script>

The browser finds the button, waits for its click event and changes the paragraph’s text. This is one of the ways a document becomes an interface someone can interact with.

JavaScript can also run on the computer hosting a website, using software such as Node.js. The language is the same, but the tools available to the program differ from those inside a browser.

Sources

← Browse Glossary: J