Account
Categories

const


Definition:

It is a place where you can store values while the program runs.

You can not change its value at any time in the program.

You can use it only inside the block {} where it is declared.

It stores the value of any type, such as a number, a string, an array, a boolean, an object, or null.

Note:

  • You cannot change the value of primitive types (number, string, and boolean) stored in a const.
  • But you can change the elements or properties of objects and arrays.
Variable Name              Value
age
---------->
5
name
---------->
"Ravi"
isStudent
---------->
true

Syntax:

const variableName = value;

Example:

const age = 5;           // number value
const name = "Ravi";     // string value
const isStudent = true;  // boolean value