🧩Constant
A named value that never changes. It stays the same the whole time a program runs.
Think of it like
Think of it like the days in a week. There are always seven, and nobody changes that.
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.
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.
Definition
Example code
javascript
const TAX_RATE = 0.2;
TAX_RATE = 0.3;
// TypeError: Assignment to constant variable.Common mistake
Key takeaways
- 1Set once. The value is given at the start and kept.
- 2One place to change. Edit one line, and every use follows.
- 3Capital names. Many teams write constants like TAX_RATE.