JavaScript by Example

Hello, World

The simplest JavaScript program - print a message to the console.

The smallest complete JavaScript program prints a message to the console - proving the runtime is wired up and your code runs.

console.log prints its argument to stdout. Every JavaScript runtime - Node.js, browser devtools, Deno, and Bun - honors it.

console.log("Hello, World!");

Running this prints:

OUTPUT
Hello, World!

In production

console.log is fine for scripts and CLI tools. In services, replace it with a structured logger like pino or winston that writes JSON - plain text logs are difficult to query in Datadog or Grafana Loki, and console.log bypasses log levels and request-ID serialization entirely.

Enjoyed this? Get more essays on software craft delivered to your inbox.

Subscribe free