Preserving value in variable is called variable initialization. You can perform initialization of the variable during the creation of the variable or at a later time when you need the change.
Note – Use the var keyword only for declarations or initializations, once for the lifetime of each variable name in the document. You can’t declare the same variable again.
Locale Variables – Locale variables will only be seen in jobs where they are defined. A service component is always available for the service. Within the body of a function, local variables take precedence over global variables with the same name. If you declare a local variable or scope variable with the same name as a global variable, you effectively hide the global variable. See the following example.