-
Constants
Constants in programming are special variables that hold once piece of data that can never change once defined. They are like defining water in chemistry - no matter what you do, water will always be defined as H20. In programming, constants can be words or letters that stand for something special. Constants allow us hold data throughout our program without having to assign them to new variables multiple times.
-
-
Immutable Constants
Javascript
Example of contant variable in javascript.
const IMMUTABLE = 'unchangeable';

console.log(IMMUTABLE); // unchangeable
const IMMUTABLE = 'unchangeable';

void main() {
 print(IMMUTABLE); // unchangeable
}

import std.stdio : write;
import std.string;

const string IMMUTABLE = "unchangeable";

void main()
{
	write(IMMUTABLE); // unchangeable
}

<?php
define('IMMUTABLE', 'unchangeable');

print(IMMUTABLE); // unchangeable
IMMUTABLE = 'unchangeable'

print(IMMUTABLE) # unchangeable
package main

import "fmt"

const IMMUTABLE = "unchangeable"

func main() {
	fmt.Println(IMMUTABLE) // unchangeable
}

-
-