On Jul 9, 6:15 pm, kstubs <kst...@gmail.com> wrote: > Wow, you just have to love Javascript, so flexible sometimes! What an > amazing language, I tell ya. > Thanks for that shortcut ilandril!
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 -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.