Declare multiple variables in JavaScript

后端 未结 5 1940
[愿得一人]
[愿得一人] 2021-02-06 21:18

I want to declare multiple variables in a function:

function foo() {
    var src_arr     = new Array();
    var caption_arr = new Array();
    var fav_arr     =          


        
5条回答
  •  余生分开走
    2021-02-06 22:10

    No, your second statement will create four references to the same array. You want:

    var src_arr     = [],
        caption_arr = [],
        fav_arr     = [],
        hidden_arr  = [];
    

提交回复
热议问题