What are variables?

Description

A variable is made up of one or more contiguous memory locations, and is used to store values of a particular type. It is a common shorthand to refer to the type of the values that can be stored in a variable, as the variable's type. The number of contiguous memory locations that make up a variable (also called the variable's size) will depend on the variable's type. It is a common shorthand to refer to the value stored in a variable, as the value of the variable, or the variable's value.

Variables are dynamic, and can be both created and destroyed. When a variable is created its initial value (i.e. its value before a value has been explicitly stored in it) is said to be undefined. It is an error to retrieve an undefined value from a variable.

Values are stored inside variables by referencing the variables in the left-hand side of assignment statements, and the values stored inside variables are retrieved by referencing the variables in expressions. NOTE: The method used to reference a variable depends on what kind of variable it is.

Variables can be grouped into the following two categories:

  1. named variables
  2. anonymous variables