|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications |

[Prev: function] [Home] [Next: Control Statements]

#### var

    var variableName;
    var anotherVariableName = InitialValue;

This keyword is used to declare and optionally initialize variables. If just the variableName is given, the variable is created, but it has no value, i.e. its value is undefined. If an InitialValue is given, the variable is created and assigned this InitialValue. Variables declared within functions are local to the function in which they are declared. Variables declared outside of functions and classes are global.

Example:

        var i;
        var count = 22;
        var str = "string";

[Prev: function] [Home] [Next: Control Statements]