# Variables
# Concepts
- In WXS, all variables reference values.
- Undeclared variables that use directly assigned values are defined as global variables.
- If you declare a variable but do not assign a value, its default value is
undefined
. - The var performance is consistent with JavaScript and variable hoisting is performed.
var foo = 1;
var bar = "hello world";
var i; // i === undefined
The above code declares three variables: foo
, bar
, and i
. Then, foo
is assigned the value of 1
and bar
is assigned the string value "hello world"
.
# Variable Names
Variable names must comply with the following rules:
- The first character must be an English letter (a-z, A-Z) or underscore (_).
- The remaining characters can be English letters (a-z, A-Z), underscores (_), or numbers (0-9).
# Reserved Identifiers
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