Some of the rules for forming variable names are as follows:
- Variable names are case sensitive.
- They must begin with a letter or the underscore character
Now let us see how to declare a variable name.
This is done by using the var statement. The syntax of var statement is
var variable name = value
In any programming language, a variable must first be declared. Storage location must be allocated for the variable before using the variable.
variable name = value
Using the variable name Exforsys and the notion that a programmer wants to assign the value “Training” to this variable it can be written two ways:
var Exforsys = “Training”
or It can also be done as follows:
Exforsys = “Training”
The variables can be declared and used in two ways namely:
This is performed using the attribute src for the <script> tag.
The script tag is placed as needed in either the HEAD section or the BODY section using the src attribute as follows: