Is it possible to create a new array, by giving it the name of the contents of a variable?
For example something like this:
var nameofarray = "array_name"; Var is a nominal one? = New array (); So that one name pharerre? gets the value of "array_name"? Thanx
Assume that you are in the global area (which is called window ): var nameofarray = "array_name"; Window [nanofre ray] = new array (); Otherwise it is only true on the object:
function a () {var nameofarray = "array_name"; Var obj = {}; Obj [nameofarray] = New Array (); }
You can also use eval which is used to evaluate the string for the javascript code:
eval ('Var' + nameofarray + '= new array ()'); It will also work in local scope, but I can never rewrite it on anyone.
You might want to read:
No comments:
Post a Comment