JavaScript Variables
0 2623
Variables can be defined as a container to store different data values which can be able to modify during program runtime.
Examples:
The variable Z is a space created inside a memory for value storage. As this value can be modified, so Z can be recognized as a Variable.
In Z, three values are stored i.e. 24, 27 and 56. The value of Z varies which is known as variable. We have created a space in a memory which was given name as Z.
In JavaScript, var statement is used for variable declaration. If we don't assign any value to a variable during declaration time, JS will automatically assign the undefined value.
Syntax of variable:
var variable-name= any value;
Example:
var z= 24;
Parameter: var is a reserved keyword
Variable-name: Name of variable
Value: it can be any initial values that are assigned during declaration time.
Rules of a Variable
a) The initial character of a variable must be an underscore, letter or a dollar sign.
b) Required initialization before implementation.
c) JavaScript permits multiple variables definition in a single line.
d) Variables used in JavaScript's are loosely-typed variable, unlike Java.
e) JavaScript is a case-sensitive scripting language.
For Example:
If we have given var_val=65; and Var_Val=65; these both statement have different meaning in JavaScript.
Share:
Comments
Waiting for your comments