What is JavaScript?

JavaScript is a dynamically typed, garbage-collected language that runs in every browser and, through runtimes like Node.js, Deno and Bun, on servers, tools and edge platforms.

It started as a small scripting language for web pages and is now standardised as ECMAScript, with a new edition every year (ES2024, ES2025...). The language itself only defines things like syntax, types, objects and promises. Everything else comes from the host environment: the browser adds the DOM, fetch, timers and storage, while Node.js adds the file system, network sockets and processes.

Key characteristics

  • Single-threaded with an event loop. Your code runs on one thread; slow work (network, timers, I/O) is handed off and its callbacks are queued, so the page stays responsive.
  • Multi-paradigm. You can write procedural, object-oriented (prototypes and class) and functional code (first-class functions, closures).
  • JIT-compiled. Engines like V8 (Chrome, Node), SpiderMonkey (Firefox) and JavaScriptCore (Safari) parse, interpret and then optimise hot code into machine code at runtime. It is not "just interpreted".
  • Dynamically typed. Types belong to values, not variables. TypeScript adds static types on top and compiles back to JavaScript.

In an interview

Mention the split between the language (ECMAScript) and the host APIs, and that the event loop is what lets single-threaded JavaScript handle concurrency.

Code example

js
1// The language: values, functions, objects, promises
2const user = { name: "Ada", skills: ["js", "ts"] };
3const greet = (u) => `Hi ${u.name}, you know ${u.skills.length} languages`;
4console.log(greet(user)); // Hi Ada, you know 2 languages
5
6// Asynchronous work is scheduled, not blocking
7setTimeout(() => console.log("3. timer callback"), 0);
8Promise.resolve().then(() => console.log("2. microtask"));
9console.log("1. synchronous code");
10
11// Modern built-ins keep arriving every year
12const grouped = Object.groupBy([1, 2, 3, 4, 5], (n) => (n % 2 ? "odd" : "even"));
13console.log(grouped); // { odd: [1, 3, 5], even: [2, 4] }

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the JavaScript set.

Open in study app