variable as index in an associative array - Javascript

前端 未结 7 1273
时光说笑
时光说笑 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;
    
    0 讨论(0)
提交回复
热议问题