concept

const

The const keyword is a fundamental programming concept used in many languages to declare variables that cannot be reassigned after initialization. It enforces immutability for the variable binding, helping prevent accidental changes to values that should remain constant throughout program execution. While the variable itself cannot be reassigned, the contents of objects or arrays declared with const may still be mutable depending on the language's implementation.

Also known as: constant, const declaration, const variable, immutable variable, read-only variable
🧊Why learn const?

Developers should use const when declaring variables that should not change during execution, such as configuration values, mathematical constants, or references to DOM elements. It improves code readability by signaling intent, enhances maintainability by preventing unintended mutations, and can help compilers optimize code. In modern JavaScript development, const is preferred over let or var for most variable declarations unless reassignment is explicitly needed.

Compare const

Learning Resources

Related Tools

Alternatives to const