Start here
JavaScript is a programming language used to give websites behaviour. It can react to a click, validate a form, update a page and request data without requiring a full page reload. The same language also runs outside browsers in runtimes such as Node.js.
You can try the first example in the Console of a modern browser without installing JavaScript. If you want to write a web page, combine a saved HTML file with JavaScript. If you want to run a .js file from a terminal or build a server, install a runtime such as Node.js. An editor helps you write code, but is not itself the runtime.
Begin with the example below. Then read variables, values, functions and decisions before moving to DOM events or asynchronous code. You can explore existing topics in any order after that foundation.
- Try JavaScript in the Playground
- Build a first interactive page
- JavaScript vs TypeScript
- Install Node.js on Windows
- Install Node.js on macOS
- Install Node.js on Linux
- Set up VS Code
- Set up WebStorm
- 1. Variables
- 2. Data types
- 3. Functions
- 4. Decisions
- 5. Selecting page elements
- 6. Responding to events
- 7. Promises and asynchronous work
Where JavaScript came from
Brendan Eich created JavaScript at Netscape in 1995. The goal was to make web pages respond to people in the browser: for example, to check input or change the page after an action. HTML already described document structure; scripts added behaviour to what had largely been static pages.
JavaScript and Java are different languages. Their names are historically linked by 1990s marketing, but their syntax, type systems and runtime models differ. Learning JavaScript does not require learning Java.
As browser support and web standards matured, JavaScript gained broader use in rich web applications. AJAX techniques let pages exchange data without full reloads; later developments included modern language syntax, modules, promises and standard browser APIs. Node.js made JavaScript practical for servers and developer tools as well. Frameworks can help organise large applications, but the language and browser fundamentals still matter.
JavaScript and ECMAScript
ECMAScript is the language specification maintained by Ecma International in ECMA-262. JavaScript is a widely used implementation of that language, together with the APIs made available by its host environment. New editions standardise language features; browsers and other runtimes implement them on their own schedules.
DOM methods such as document.querySelector and web features such as fetch are not defined by ECMAScript itself. Browsers provide these APIs alongside an ECMAScript engine. Node.js provides its own runtime APIs, such as file-system access. Some APIs exist in both places, but you must check the environment before using one.
How JavaScript runs
A JavaScript engine reads source code, parses it and executes the instructions. Modern engines use techniques including compilation and optimisation while a program runs. “Interpreted” is therefore an incomplete description of how every modern engine works. Examples of engines include V8 and SpiderMonkey.
A runtime combines an engine with surrounding facilities. In a browser, the runtime supplies the page environment, DOM, timers, network interfaces and events. A script can change a page only when the browser gives it access to that page. Browser security rules restrict what a page can read from other sites or from your computer.
Node.js is a separate runtime that uses a JavaScript engine to execute code outside the browser. It can build a server, run a command-line tool or read files when your program has the required access. It does not automatically have a webpage or a document object. JavaScript is the language; Node.js is one environment that runs it.
The DOM and interactive pages
When a browser loads HTML, it creates a Document Object Model (DOM): an in-memory representation of the document as objects. JavaScript can find an element, change its text or attributes and respond to events such as clicks. The browser then updates what people see.
For example, a page could show a “Show answer” button. An event listener waits for the click, finds the answer element and changes its text. HTML supplies the button and answer, CSS controls their appearance, and JavaScript supplies the click behaviour. A console message appears in developer tools; changing an element changes the webpage itself.
This is why JavaScript is useful for interactive sites: it lets the page respond to users and incoming information. Important content and controls should still have clear HTML structure so the page is usable and understandable.
What asynchronous JavaScript means
Some work takes time: a network response, a timer or a user action. JavaScript can start that work, allow other tasks to proceed and handle the result when it becomes available. This is asynchronous programming. A Promise represents a result that may arrive later; async and await provide a way to write code that waits for a Promise without blocking the whole page.
Imagine clicking “Load weather”. The page can show a loading message while a request is pending, then display the weather or an error. The network request is initiated by a browser API; JavaScript handles the returned Promise. A pending request can finish after a newer one, so applications also need an error and stale-result policy. Asynchronous code is not a guarantee that every operation runs in parallel.
What people build with JavaScript
These are examples of where the language is useful. Each needs the appropriate browser or other runtime and often additional libraries or platform tools. JavaScript alone does not automatically supply a mobile app, desktop window or server.
| Use | Why JavaScript helps | Example |
|---|---|---|
| Interactive websites | Respond to input and change the current page. | Open an accessible menu when its button is clicked. |
| Frontend development | Combine page state, browser APIs and UI components. | Filter a product list as someone types. |
| Web applications | Coordinate several interactive screens and server responses. | Update a project board after moving a task. |
| Backend development | A server runtime can handle requests and business rules. | Validate a submitted order with Node.js. |
| APIs and servers | Return structured data to a browser or another program. | Serve a JSON list of available appointments. |
| Mobile applications | A framework or web platform can package or deliver interfaces. | Build a phone-friendly booking app; platform APIs require the relevant tools. |
| Desktop applications | A desktop framework can pair JavaScript UI code with native integration. | Create a cross-platform notes app. |
| Automation and tooling | Runtime scripts can repeat project or data tasks. | Check files before a release or transform a JSON report. |
| Real-time applications | Event and network APIs can react to incoming updates. | Display new chat messages from a server connection. |
| Other uses | The language can work wherever a suitable runtime is provided. | Write browser extensions or test a web interface. |
Strengths and limitations
A major advantage is availability: modern browsers already run JavaScript, so a learner can start with a console and a small web page. The language also works across browser and server projects, and its broad ecosystem provides libraries, documentation and tools. Event-driven code suits interactive interfaces and network applications.
The same flexibility requires care. JavaScript checks many kinds of mistakes only when the relevant code runs; automated tests and optional tools such as TypeScript can help detect some problems earlier. A large dependency tree can add maintenance and security work. Browser scripts are restricted by origin and permission rules, and those limits cannot be removed just by choosing JavaScript.
Long CPU-heavy work on the browser main thread can make a page unresponsive. Workers or a server can move suitable work elsewhere, but they add complexity. Browser engines and Node.js releases do not always support new features at the same time. Test on the environments you actually intend to support. JavaScript can be a strong choice without being the best choice for every task.
Your first program
Open your browser developer tools, select Console, enter the statement below and press Enter. You should see Hello, Codectionary! in the console. console.log is a method provided by the environment’s console API: it sends the value you pass to a developer-facing log. The quotes mark a string in the source; they are not part of the message.
This does not put text on the webpage. To show a message on a page, you would use HTML or change a DOM element. You can run the same line from a saved .js file with Node.js after installing Node, where it writes to the terminal instead. Try changing the message and running it again.
Syntax
console.log("Hello, Codectionary!");Examples
Print a first message
Run this in a browser console or with Node.js. Expected console output: Hello, Codectionary!
console.log("Hello, Codectionary!");- console is the logging object supplied by the browser or Node.js runtime; log is its method for writing a message.
- The string between quotes is the value passed to log. The semicolon ends the statement; JavaScript can often insert one automatically, but writing it here makes the boundary clear.
- The message appears in the browser developer console or in the Node.js terminal, depending on where you run it. It does not appear as page content.
- Change the string and run the code again. Checking the actual output after a small edit is a useful habit when learning and debugging.
JavaScript: background & uses
- Used for
- Interactive websites, Web applications, Server APIs
- Created by
- Brendan Eich at Netscape
- First released
- 1995 · browser debut
- Version / standard
- ECMAScript 2026
17th edition of the language standard. Browser and runtime support varies.
In the real world
- Netflix: The netflix.com browser interface
- PayPal: The JavaScript checkout SDK
- GOV.UK: Interactive GOV.UK Frontend components
Facts checked 8 September 2026. Product links describe documented uses.
Best practices
- Start with browser JavaScript before adding a framework or a server runtime.
- Check where code runs: DOM code needs a page, while local file access needs an appropriate runtime and permissions.
- Read errors in the console and test small changes before adding more code.
- Treat input and network responses as untrusted; check them before using them.
Runtime & versions
Browsers and JavaScript runtimes. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
ECMAScript specification