• 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
      • Dart

        Example of contant variable in dart.
        const IMMUTABLE = 'unchangeable';
        
        void main() {
          print(IMMUTABLE); // unchangeable
        }
        
      • D

        Example of contant variable in d.
        import std.stdio : write;
        import std.string;
        
        const string IMMUTABLE = "unchangeable";
        
        void main()
        {
        	write(IMMUTABLE); // unchangeable
        }
        
      • Php

        Example of contant variable in php.
        <?php
        define('IMMUTABLE', 'unchangeable');
        
        print(IMMUTABLE); // unchangeable
      • Python

        Example of contant variable in python.
        IMMUTABLE = 'unchangeable'
        
        print(IMMUTABLE) # unchangeable
      • Go

        Example of contant variable in go.
        package main
        
        import "fmt"
        
        const IMMUTABLE = "unchangeable"
        
        func main() {
        	fmt.Println(IMMUTABLE) // unchangeable
        }