tencent cloud

All product documents
Tencent Cloud Super App as a Service
Variables
Last updated: 2025-03-25 11:41:05
Variables
Last updated: 2025-03-25 11:41:05

Concepts

Variables in WXS are references to values;
Variables that are not declared and used by direct assignment are defined as global variables;
If a variable is declared without being assigned a value, the default value is undefined;
var behaves in the same way as javascript, there will be variable lifting.
var foo = 1;
var bar = "hello world";
var i; // i === undefined
In the above code, three variables foo, bar and i are declared. Then, foo is assigned the value 1 and bar is assigned the string "hello world".

Variable Naming

Variable naming must conform to the following two rules:
The first character must be: letter (a-zA-Z), underscore (_);
The remaining characters can be: letters (a-zA-Z), underscore (_), numbers (0-9).

Reserved 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
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon