const- is a constant value that can be used like a variable but cannot be changed.
You need to use the
const keyword to define constant:
Constants should be named in UPPER_SNAKE_CASE style. The snake_case means that words will be tied by the
_symbol. The UPPER means that words will be written in uppercase.
Look at the example with a changeable variable:
Trying to change the value of the constant should cause the
Also, you cannot define a const without a value: it will cause the
Constants are used like unchangeable variables. You can define constant one time and use it multiple times.
Constants provide data integrity with the ability to refactor quickly.
Refactor is a change code structure. (Change names of variables, values, etc.)
MAX_HEIGHT for site elements. You can release the site update by changing the maximum height of the elements by modifying only one value in the code. However, during runtime, it is not possible to change the maximum height, which ensures the integrity of data:
Constants can receive every value that variables can receive.