JavaScript var
JavaScript var
Variables are containers that are used for storing information. The var statement is used for declaring a variable. Creating and declaring a variable are the same. After declaring a variable we have to assign a value to it. For this purpose, we have to use an equal sign to assign value. All of these steps are:-
- var name;
- name = "Sita";
OR
- var name = "Sita";
Syntax:-
Its syntax is:- var name = value;
Further Explanation:-
Parameter | Description |
name |
Required. The name of the variable and must follow rules. These rules are:-
|
value | Optional. A value to be assigned to the variable. |