Episode 1 — Fundamentals / 1.13 — Introduction to JavaScript

1.13.a — What is JavaScript?

In one sentence: JavaScript is a high-level, interpreted programming language that adds interactivity and logic to web pages — and today it also runs on servers, CLIs, and mobile, making it one of the most widely used languages in the world.

Navigation: ← 1.13 Overview · 1.13.b — Where JavaScript Runs →


1. What is JavaScript?

JavaScript (often abbreviated JS) is a language you use to tell the computer what to do with data and events: react to clicks, validate forms, fetch new content without reloading the page, animate UI, and build entire single-page applications.

LayerTechnologyRole
StructureHTMLWhat is on the page (headings, links, forms)
PresentationCSSHow it looks (layout, color, typography)
BehaviorJavaScriptHow it behaves (logic, updates, communication)

The three work together: HTML exposes elements the user sees, CSS styles them, and JS reads and changes the DOM (the in-memory tree of the page) and reacts to user input.


2. Why JavaScript powers the web

  1. Ubiquity — Every major browser ships a JavaScript engine (V8 in Chrome/Edge, SpiderMonkey in Firefox, JavaScriptCore in Safari). If you write JS for the browser, it runs for billions of users without installing a runtime on their machine.
  2. The web platform — Browsers expose Web APIs (DOM, fetch, timers, storage, WebSockets, etc.). JS is the standard way to use those APIs.
  3. Node.js — The same language on the server and in build tools (bundlers, linters, test runners). One language across the stack lowers context switching for teams.
  4. Ecosystem — npm hosts a huge library ecosystem; frameworks (React, Vue, Svelte, etc.) are all JS-first.

3. A mental model: program vs engine

  • Source code — Text you write in .js files (or inline in HTML).
  • Engine — Reads and executes that code (plus JIT optimization in modern engines).
  • Host — Browser or Node provides globals and APIs (document in the browser, fs in Node — not available in both).

Same language syntax; different capabilities depending on where it runs (see 1.13.b).


4. Is JavaScript the same as Java?

No. They are unrelated languages; the name was historical marketing. Do not confuse them in interviews or documentation.


5. Key takeaways

  1. JS is the behavior layer of the web alongside HTML and CSS.
  2. It is everywhere in browsers and, via Node, on servers and tooling.
  3. Your code runs inside an engine hosted by a browser or Node — APIs differ by environment.

Explain-It Challenge

Explain without notes:

  1. In one sentence each: what HTML, CSS, and JavaScript are responsible for on a typical page.
  2. Name two reasons businesses choose JavaScript for web front ends.
  3. What is the difference between the JavaScript language and the browser as a place where JS runs?

Navigation: ← 1.13 Overview · 1.13.b — Where JavaScript Runs →