W3docs

Welcome to JavaScript!

What JavaScript is, where it runs (browser and Node.js), what it can do, and why it is worth learning — a beginner-friendly introduction with examples.

JavaScript (often shortened to JS) is the programming language of the web. It started as a way to make web pages interactive, and it now powers everything from buttons and animations in the browser to full backend servers built with Node.js. It is one of the few languages you can use from the front end all the way to the back end, which is a big part of why it is so popular.

This page covers what JavaScript is, the two places it runs (the browser and a server), what it can do, and why it is worth learning. By the end you will understand where JavaScript fits and what to study next.

What is JavaScript?

JavaScript was created in 1995 by Brendan Eich at Netscape. It was designed to make web pages respond to user actions — clicking buttons, filling out forms, or showing content without reloading the page.

The language is standardized under a specification called ECMAScript. Each yearly edition adds features; the 2015 edition (commonly called ES6) was a major leap that introduced arrow functions, template literals, classes, and modules. When people say "modern JavaScript," they usually mean ES6 and later.

A few terms that describe JavaScript and that you will see often:

  • High-level — you do not manage memory or hardware directly.
  • Dynamically typed — a variable can hold any type, and the type is checked while the program runs rather than before.
  • Interpreted (JIT-compiled) — code runs without a separate compile step; the engine (such as Chrome's V8) compiles it on the fly.

Despite the name, JavaScript is not related to Java. The name was a marketing decision; the two languages are entirely different.

Here is a small program that prints a message — this is the kind of code that runs the same in a browser console or in Node.js:

const language = "JavaScript";
console.log(`Hello from ${language}!`);
// Output: Hello from JavaScript!

What Can JavaScript Do?

  • Update the page on the fly. JavaScript can change what is on a web page without loading a new one. This is done through the DOM (Document Object Model), the browser's live representation of the page.
  • React to events. It runs code in response to clicks, key presses, scrolling, form submissions, and more.
  • Talk to servers asynchronously. It can fetch data in the background (for example, checking a username while the user keeps typing) without freezing the page.
  • Store and process data. It has built-in support for arrays, objects, dates, math, and text processing.

For example, this changes the main heading of a page when it runs in a browser:

// Runs in the browser: replace the text of the first <h1>
document.querySelector('h1').textContent = 'Hello, JavaScript!';

Where JavaScript Runs

JavaScript needs an engine to run. The two most common environments are the browser and Node.js.

In the Browser

Every modern browser (Chrome, Firefox, Safari, Edge) has a built-in JavaScript engine. This is where JavaScript started, and it is what makes web pages interactive. You add JavaScript to an HTML page with the <script> tag:

<!-- Load an external file -->
<script src="app.js"></script>

<!-- Or write code inline -->
<script>
  console.log('This runs in the browser.');
</script>

You can try JavaScript right now without writing any HTML: open your browser's developer tools (press F12, or Ctrl+Shift+I / Cmd+Option+I on a Mac), click the Console tab, and type code directly.

On a Server with Node.js

Node.js lets you run JavaScript outside the browser — on a server, your laptop, or in build tools. A server is a computer that responds to requests, for example by sending back a web page or data.

  • One language, front and back. You can write both the part users see and the server logic in the same language, which simplifies development.
  • Good at I/O-heavy work. Node.js handles many simultaneous connections efficiently, which suits APIs and real-time apps like chat.
  • A huge package ecosystem. Node.js comes with npm, the largest software registry in the world, so you can pull in ready-made tools instead of writing everything yourself.

The key difference: code in the browser can touch the page and the user (document, window), while Node.js code can touch the system (files, network servers) but has no page. The core language is the same in both.

Why Learn JavaScript?

  • It is everywhere. Nearly every website uses JavaScript, so it is a foundational skill for web development.
  • It opens doors to frameworks. Learning it lets you use popular tools like React, Angular, Vue.js, and Node.js for building larger apps.
  • It runs almost anywhere. Beyond the web, JavaScript builds mobile apps (React Native) and desktop apps (Electron).
  • It has a large community. Plenty of tutorials, libraries, and help are available when you get stuck.
  • It is in demand. Many jobs ask for JavaScript skills.
  • It gives fast feedback. You can see your code work immediately in the browser, which makes learning enjoyable.

Next Steps

Now that you know what JavaScript is and where it runs, the best way to learn is to write some. Good next chapters:

Whether you want to build a website, write server apps, or simply learn to program, JavaScript is a great place to start. Keep learning with us at W3Docs.

Practice

Practice
Which of the following statements are true about JavaScript?
Which of the following statements are true about JavaScript?
Was this page helpful?