One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language.
Numbers eg. 123, 120.50 etc.
Strings of text e.g. “This text string” etc.
Boolean e.g. true or false.
You can also declare multiple variables with the same var keyword as follows:
Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or later point in time when you need that variable as follows:
For instance, you might create a variable named money and assign the value 2000.50 to it later. For another variable you can assign a value the time of initialization as follows:
Note: Use the var keyword only for declaration or initialization.once for the life of any variable
name in a document. You should not re-declare same variable twice.
Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.
Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global variable, you effectively hide the global variable. Following example explains it:
This produces the following result: