HAKATEMIA
04JavaScript

Let vs. Const: Declaring Variables in JavaScript

Easy10MIN

Let and Const

In JavaScript, there are different ways to declare variables. Two modern keywords you'll use are let and const. Think of these as different types of wires:

  • let creates a wire that can be reconnected to different values later.
  • const creates a wire that is fixed to one value and cannot be changed once set.

While you might also encounter var, it is an older way to declare variables and has quirks that can lead to errors. While it's good to know that var exists since you might encounter it, it's best to use let and const.

1 / 6
Hakatemia Pro

Learn to hack — start here

Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.