You can even use an expression within the square brackets:
var idx = itt + 1;
var h = {};
h['p_Value' + idx.toString()] = names[itt];
...but you probably want that `name` variable for something else
anyway.
This is all a consequence of the fact that object property names are
strings, and so these all set the same property of `a` to `bar`:
a.foo = bar;
a['foo'] = bar;
x = 'f'; a[x + 'o' + 'o'] = bar;
These are also identical:
a[0] = bar;
a['0'] = bar;
...and in fact, we all use the fact that a number within the brackets
is converted to a string property name all the time, whenever we use
an "array" -- because JavaScript arrays aren't really arrays at all:
http://blog.niftysnippets.org/2011/01/myth-of-arrays.html
FWIW,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com