Use the var keyword to declare (create) a variable:
Examples of declaring variables:
var x; var number;
Variable names start with a letter (az, AZ) or an underscore _ followed by any letter or number and underscores, but not spaces. In addition, variable names are case-sensitive.
These variable names are valid as follows:
var_char varchar _varchar char5Note
For variable naming, we recommend that variable names be preferred to indicate a combination of their actual semantics, such as my_name or myName.
You can assign variables to variables while declaring variables:
var my_name = "Jack"; // Text character variable, enclosed in double quotation marks var number = 2; // Numeric variable
my_name = "Jack"; number = 2;
The assigned variable is automatically declared, but pre-declaration of a variable is a good programming practice.
Examples of using variables
The pop-up prompt box will output:
My name is Jack, I am 25 years old.
The above simple demonstration of the application of variables, as can be seen from the above example, the variable can not be written with the string in double quotation marks, but need to connect with the + link, otherwise the variable will be as ordinary string output.