Something like this would work:

foo("bar");

function foo(prop) {
    window[prop] = 1;
}

Ted


On Sat, Nov 15, 2008 at 1:24 PM, 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.
>

Reply via email to