Store javascript variable into array

This question already has an answer here:

  • How to append something to an array? 25 answers

  • There are several ways to do it:

    var array1 = [var1, var2, var3, var4];
    var array2 = new Array(var1, var2, var3, var4);
    

    or

    var array3 = new Array;
    
    array3.push(var1);
    array3.push(var2);
    array3.push(var3);
    array3.push(var4);
    

    Have fun!


    Take a look into JSON as data format.

    var data = <?= json_encode([$fxVal, $equitiesVal, $boVal, $account_balance]); ?>;
    

    When you want to send or receive more data consider using AJAX.

    链接地址: http://www.djcxy.com/p/17930.html

    上一篇: array.push(element)vs array [array.length] =元素

    下一篇: 将javascript变量存储到数组中