Skip to content

Constant

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

A constant is a box you seal shut after putting something in. You can look inside any time you want, but you can't swap out what's in there. It's perfect for things that should never change, like the number of days in a week.

Real Talk

A constant is an immutable variable — its value is set once and cannot be reassigned. Constants communicate intent to other developers and prevent accidental mutations. They are declared with const in JS/TS, final in Java, or let in Rust.

Show Me The Code

const MAX_RETRIES = 3;
const API_BASE_URL = "https://api.example.com";

// MAX_RETRIES = 5; // TypeError: Assignment to constant variable

When You'll Hear This

"Put that magic number in a constant with a good name." / "Never hardcode values — use constants."

Made with passive-aggressive love by manoga.digital. Powered by Claude.