# variable

# concept

  • Variables in WXS are references to values.
  • Variables that are not declared are used directly assigned a value and are defined as global variables.
  • If you declare a variable without assigning a value, the default value isundefined.
  • Var performance is consistent with javascript, there will be variable promotion.
var foo = 1;
var bar = "hello world";
var i; // i === undefined

The above code separately declares [[ TAG-0-START]] foobariThree variables.Then,fooassigns a value [[ TAG-4-START]] 1barTo the character string"hello world"

# Variable name

The variable name must conform to the following two rules:

  • First character must be: letter (a-zA-Z), underscore (_)
  • The remaining characters can be: letters (a-zA-Z), underscores (_), numbers (0-9)

# Retain the identifier

The following identifiers cannot be used as variable names:

delete
void
typeof

null
undefined
NaN
Infinity
var

if
else

true
false

require

this
function
arguments
return

for
while
do
break
continue
switch
case
default