I need to define a hash for posting some ajax data using jQuery. The hash will look something like:
var setname = 'set_1';
elements = { set_1: {'beer','water','wine'} };
The challenge I need to solve is 'set-1' (the key of Array elements) should be dynamically named based on the value of var setname
.
I want to avoid using eval()
of course..
in PHP it can be done using the double dollar sign like this: $$setname
, but what's the way to do this in JavaScript?