Hello World
JavaScript · Reference cheat sheet
Hello World
JavaScript · Reference cheat sheet
📋 Overview
Hello World confirms your JS environment works. The usual first call is console.log, which writes to the browser console or the terminal (Node).
🔧 Core concepts
| Piece | Role |
|---|---|
console.log(...) | Print values for humans / debugging |
| String literal | "text" or 'text' or `text` |
| Statement | An instruction, often ending with ; (ASI may insert them) |
| Script | Code loaded by Node or a browser |
Semicolons are recommended for beginners even though Automatic Semicolon Insertion exists.
💡 Examples
Node script:
console.log("Hello, World!");node hello.jsMultiple values:
const name = "Ada";
console.log("Hello,", name);
console.log(`Hello, ${name}!`);Browser alert (UI, not for real apps):
alert("Hello, World!");Log different types:
console.log(42);
console.log(true);
console.log({ ok: true });
console.log(["a", "b"]);⚠️ Pitfalls
- In the browser, look at the Console tab — not the page body — for
console.log. alertblocks the UI; use it sparingly while learning.- Smart quotes from documents break string literals.
- Running TypeScript (
.ts) needs a toolchain; plain Hello World should be.js.