JavaScript Introduction
What JavaScript is, where it runs (browser and Node.js), and how the language has evolved since ES2015.
What is JavaScript?
JavaScript is a high-level, dynamically typed scripting language originally created by Brendan Eich in 1995 — famously in just 10 days — to make web pages interactive. Despite the name, it has no formal relationship to Java; the name was largely a marketing decision during the browser wars of the mid-1990s.
The language itself is standardized as ECMAScript (the spec) under ECMA International. "JavaScript" and "ECMAScript" are used almost interchangeably in practice — when someone says "ES2022 features," they mean the version of the JavaScript language spec ratified in 2022.
console.log("Hello, World!");
Where JavaScript runs
JavaScript started as a browser-only language, but it now runs in two very different environments:
- The browser — every major browser (Chrome, Firefox, Safari, Edge) embeds a JavaScript engine (Chrome and Edge use V8, Firefox uses SpiderMonkey) that executes JS to manipulate the page (the DOM), handle user interaction, and talk to servers.
- Node.js — a runtime built on Google's V8 engine that runs JavaScript outside the browser, on a server or your local machine. Node.js is what lets JavaScript power backends, CLI tools, and build scripts.
This is the single most important thing to understand about modern JavaScript: it's one language, but two very different runtime environments, each with their own APIs (the browser gives you document and window; Node gives you fs and process, but no document at all).
How the language has evolved
JavaScript changed remarkably little between 1995 and 2015. Then ES2015 (also called ES6) landed and modernized the language dramatically, and a new yearly spec has shipped every year since:
- ES2015 (ES6) —
let/const, arrow functions, classes, template literals, Promises, destructuring, modules. - ES2017 —
async/await. - ES2020 — optional chaining (
?.), nullish coalescing (??). - ES2022 — top-level
await, class private fields (#field).
Modern JavaScript (what this tutorial series teaches) means writing code the ES2015+ way: const/let instead of var, arrow functions and async/await instead of raw callbacks, and template literals instead of string concatenation.
Hello World in the browser
<!DOCTYPE html>
<html>
<body>
<script>
console.log("Hello, World!");
document.body.textContent = "Hello, World!";
</script>
</body>
</html>
Open this file in a browser and open its developer console (F12) to see the logged message, and the page itself will display the text.
Hello World in Node.js
Install Node from nodejs.org (the LTS version is the safe default), then verify it:
node --version
# v20.14.0
Save a file as hello.js:
console.log("Hello, World!");
Run it directly from the terminal — no browser, no HTML needed:
node hello.js
# Hello, World!
What JavaScript is used for today
- Frontend web — every interactive website, from simple form validation to full single-page apps (React, Vue, Svelte).
- Backend — Node.js powers a huge share of production APIs and services (Express, Fastify, NestJS).
- Mobile — React Native compiles JS-based UI code to native iOS/Android apps.
- Desktop — Electron (VS Code, Slack, Discord's desktop app) wraps a browser engine to build cross-platform desktop apps in JS/HTML/CSS.
Common mistakes
- Writing "old-style" JavaScript learned from an outdated tutorial —
var, callback pyramids, string concatenation with+— when modernconst/let,async/await, and template literals are clearer and safer. - Assuming browser JS and Node.js share all the same built-in objects —
documentandwindowonly exist in the browser;require/importof Node built-ins likefsonly exist in Node. - Confusing "JavaScript" the language with "ECMAScript" the specification — they're effectively the same thing, just named by two different standards processes.
Interview questions
Q: Is JavaScript related to Java? No, only in name. They have entirely different syntax, semantics, and runtimes — the shared name was a marketing decision by Netscape in 1995 to ride Java's popularity at the time.
Q: What's the difference between JavaScript and ECMAScript? ECMAScript is the formal language specification maintained by ECMA International (TC39 committee); JavaScript is the most well-known implementation of that specification. In everyday conversation the two terms are used interchangeably.