# Constant

> A named value that never changes. It stays the same the whole time a program runs.

**Field:** Software Development  
**Category:** Programming Concepts

## Think of it like

Think of it like the days in a week. There are always seven, and nobody changes that.

## Definition

A constant names a value that never changes while a program runs. Tax rates, the number of days in a week and a site's address are common ones. Some languages, like JavaScript, stop you if you try to change a constant. Others, like Python, only ask you to write the name in capitals. Either way, a constant tells the reader to leave this value alone.

## Example

A shop sets TAX_RATE to 0.2 once, at the top. Every price uses it, so a new rate is a change to one line.

## Example code

```javascript
const TAX_RATE = 0.2;
TAX_RATE = 0.3;
// TypeError: Assignment to constant variable.
```

JavaScript says no to the second line, since the value is fixed.

## Why it matters

A value written once in a constant is changed in one place. The same number typed in ten places gets missed in one.

## Common mistake

Typing the same number all over the code. When it changes, one copy always gets left behind.

## Three principles

- **Set once.** The value is given at the start and kept.
- **One place to change.** Edit one line, and every use follows.
- **Capital names.** Many teams write constants like TAX_RATE.

## Related terms

- [Variable](https://learn.benibix.com/term/development/variable)
- [Assignment](https://learn.benibix.com/term/development/assignment)
- [Data Type](https://learn.benibix.com/term/development/data-type)
- [Keyword](https://learn.benibix.com/term/development/keyword)
- [Hard-Coding](https://learn.benibix.com/term/development/hard-coding)
- [Enumeration (Enum)](https://learn.benibix.com/term/development/enum)

## Taught in

- [Variables and Assignment](https://learn.benibix.com/learn/development-concepts/variables-and-assignment): Programming Basics, 5/18

---

Source: https://learn.benibix.com/term/development/constant
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
