Creating a javascript object with dynamic property name

Firat Tiryaki

You should use eval function for that.

Check out the below lines, sure it will help;

x=new Object();
propertyName="nameProperty";
propertyValue="John";
eval("x."+propertyName+"='"+propertyValue+"'");
alert(x.nameProperty);

About | Sitemap | Contact