variable as index in an associative array - Javascript

前端 未结 7 1292
时光说笑
时光说笑 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-03 23:51

    Are you looking for variableName = 'bla'+'foo'; arrayRef[variableName] = 'something'; ?

    And even so, you should use an object literal instead. x = {}; x[variablename] = 'blah';

提交回复
热议问题