HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to JavaScriptVariables (let / const)Data TypesOperatorsStringsArraysObjectsConditions (if / else)Loops (for / while)FunctionsArrow Functions (=>)Array Methods (map / filter / reduce)
REFERENCE
📖 Overview
🖥️ Output & Console
📦 Variables
let / constvar (legacy)
🔢 Numbers & Math
✍️ String
📋 Array
🗂️ Object
🔁 Condition & Loop
🧩 Function
🔄 Type & Conversion
JavaScript›REFERENCE›Variables›let / const

let / const

Defines variables; const does not change.

Syntax

let name = value;
const constant = value;

Description

You define variables that can be changed later with let, and unchanging (constant) variables with const. Default choice is const; use let only if it will change.

Returns

—

Example

Loading editor…

Expected output

1 3.14

When to use?

Storing all kinds of data. const makes code safer (prevents accidental changes).

Common mistakes

  • ⚠️ Reassigning to a const throws an error (TypeError).
  • ⚠️ Using a variable before defining it throws an error.

Related commands

var (legacy)console.log()
var (legacy) →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code