concept

const

const is a keyword in programming languages like JavaScript, C++, and Java that declares a variable as constant, meaning its value cannot be reassigned after initialization. It enforces immutability for primitive values and prevents reassignment for reference types, though the contents of objects or arrays may still be mutable. This helps prevent accidental changes to data and makes code more predictable and easier to debug.

Also known as: constant, const variable, const declaration, immutable variable, const keyword
🧊Why learn const?

Developers should use const when they need to declare variables that should not be reassigned, such as configuration values, mathematical constants, or references to DOM elements. It is particularly useful in modern JavaScript development to enforce functional programming principles and reduce bugs caused by unintended mutations, making code more maintainable and readable in frameworks like React or Node.js.

Compare const

Learning Resources

Related Tools

Alternatives to const