Variables and Constants

Top  Previous  Next

 

A variable is identified through a unique name and contains a defined value of a specific type.

 

The very first value assigned to a variable also defines its type. A type simply tells the scripting language how to handle the data that is contained in a variable. Once an initial value has been assigned and thus a type defined, the value can be changed but not the type.  For example, if a variable's type is a string because it's first value is: 'HelloWorld', then that variable can only hold other string values.  Just remember that while it is possible to change the value of a variable with the same type, you can not assign a value of a different type.

 

A constant is identified through a name and has a specific value, unlike the variable, this value cannot be modified.  This simply means that a constant can have only the value which it was first assigned.