tencent cloud

Feedback

Variable

Last updated: 2024-07-12 16:57:40

    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
    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 avaliable.

    7x24 Phone Support