In the above example, we have declared three variables using var keyword: one, two and three respectively. After that, we have assigned values to variables one and two at the time of declaration, whereas variable three is declared but the value is not assigned to it, so its value will be ‘undefined’.
Declare Variables in a Single Line:
Multiple variables can also be declared in a single line separated by a comma.
Note: It is not recommended to declare a variable without var keyword because it can accidentally overwrite an existing global variable.
The region of your program in which variable is defined is called scope.
A local variable has a local scope which means it will be visible only within a function where it is defined. Function parameters are always local to that function.