Variables
-Variables are derived from mathematics and are abstract concepts in computer languages that can store calculation results or represent values -Variables can be accessed through variable names -Z1h language variable names are composed of letters, numbers, symbols and other characters, the first character cannot be a number
the general form is used to declare variables keyword var
: var variable name = variable value
may involve multiple variables:
variable name variable value 1 = 1, variable name 2 = variable value 2 ;
or
variable name 1, variable name 2 = variable value 1, the variable value of 2;
global variable
using: =
connected variable name and value, may declare a global variable
name: = "aaa"
Scope
of variables-Variables declared in var within functions, loops and other code blocks, scope is limited to this code block
-if var variable declaration is not used, directlyvariable name = variable When the value is
, if the variable name already exists, the value will be overwritten, otherwise a ** global variable ** will be created-
the variable declared withvariable name: = variable value
will become the global variable directly