how to create and assign a value to a variable created dynamically?

后端 未结 3 1964
闹比i
闹比i 2021-01-07 03:27

I\'m trying to get this to work:

function whatever(arg) {
  eval(arg) + \'_group\' = [];
}

The purpose is to have only 1 function instead h

3条回答
  •  梦毁少年i
    2021-01-07 04:00

    Although you really shouldn't use eval this should help

    eval(arg + '_group') = [];

提交回复
热议问题