typeover
curriculum

Curriculum Foundations Variables and declarations exercise 3 · mcq

Variables and declarations

TS const means "this binding can't be reassigned." Go const means something stricter — "compile-time constant." For a value that's genuinely fixed at compile time, which Go matches this TS?

TypeScript reference
Pick the idiomatic Go translation

About this theme

TypeScript uses let and const to introduce variables; the type is inferred or annotated explicitly. Go has two short forms for the same job:

  • name := value — the short declaration. Inferred type. Idiomatic at function scope. This is what you'll write most of the time.
  • var name type = value — the full form. Required at package scope and useful when you want to declare without initialising, or pin the type explicitly.

const exists in Go too, but only for compile-time constants (integers, strings, floats, booleans) — not for "this binding doesn't get reassigned" the way TS uses const. We'll come back to that.