A variable is a name allocated to a storage area that can be controlled by the programme. A type of variable specifies the size and configuration of the memory of the variable.
The range of the value that can be inserted into a variable is calculated before inserting the value into it, as the type of the variable must be decided before inserting the value into it.
Scope of Variables
A variable's scope is literally a variable's lifespan. It is a code block in which a variable is valid or still alive.
function poo() {
var a;
}
Within the "a" function, we declare a variable "poo." The scope of that variable remains within that function, and cannot be used outside that function.
There are three places where we can utilize the variable in our programming.
In a function or inside a block then it is said to be Local variables
If used outside of all functions then it is named as Global variables
If used in the function parameters definition then it is termed as formal parameters.