I want to name an array a random number, theoretically.
var arrayname = "foo";
(the value of arrayname) = ["1", "2", "3"]
Is this possible?
I want to name an array a random number, theoretically.
var arrayname = "foo";
(the value of arrayname) = ["1", "2", "3"]
Is this possible?
You can create object with arrays as properties. Property name could represent array name. For example:
var arrays = {
foo: ["1", "2", "3"],
other: ["4", "5"]
};
var arrayname = "foo";
console.log(arrays[arrayname]);
var dates = {};
var cdate = new Date(),
arrayname = Math.floor(cdate.getTime()+Math.random()*16),
arrayname = "time_"+arrayname;
dates[arrayname] = ["1", "2", "3"];
// to retrieve
console.log(dates[arrayname]);
You could try the window
object. Or use an array to hold your array.
var arrayname = "foo";
window[arrayname] = ["1", "2", "3"];
console.log(foo); // ["1", "2", "3"]