html - How to make variables with a function javascript? -


i've been in automated tasks while want allow user create own variable way a = myname = guy (a) = an quite useful please don't use dictionary. same normal variable!

you can this:

function setvariable(varname, value){   this[varname] = value; } 

this create variable value , name on window object or on object function attached (calling context).

remember objects hash tables, can get/set variables this

obj["var1"] = 123; var var1 = obj["var1"]; 

so it's can set using string name of object member name.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -