Something like : ------------------------------ function foo(x) { window[x] = 1; }
foo('bar'); alert(window.bar); ---------------------------- On 15 nov, 19:24, Johnnie Walker <[EMAIL PROTECTED]> wrote: > Hi, > > Is there any way to add a property named via a variable to a > javascript object? > > this is what I would like to do: > > -------------------------------- > > foo(bar); > > function foo(x) > { > window.x = 1;} > > ---------------------------------- > > so that the object window will end up with a property called bar. i.e. > window.bar==1 > > Any ideas? > > John.