variable as index in an associative array - Javascript

前端 未结 7 1287
时光说笑
时光说笑 2021-02-03 23:39

I\'m trying to create an associative array, create an empty array, and then add a (indexName -> value) pair:

var arrayName = new Array;

arrayName[\         


        
7条回答
  •  忘了有多久
    2021-02-04 00:09

    You want a plain object with the same bracket notaiton here, like this:

    var arrayName = {};
    arrayName["indexName"] = value;
    

提交回复
热议问题