how to create and assign a value to a variable created dynamically?
问题 I'm trying to get this to work: function whatever(arg) { eval(arg) + '_group' = []; } The purpose is to have only 1 function instead having three with basically the same content but with different variable names. At the end I want to have something like: a_group = []; b_group = []; Doing this way, I'm getting the error: ReferenceError: Invalid left-hand side in assignment EDIT Here is the original function that I'm trying to make work. But it won't work. function collect_all_values_for(field