Multiple variables can also be declared with the same var keyword as follows:
- 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. Whenever a local variable or a function parameter with the same name is declared it effectively replaces the value of the global variable. Taking a look at the example below: