Q:

Javascript using variable as array name

I have several arrays in Javascripts, e.g.
a_array[0] = "abc";
b_array[0] = "bcd";
c_array[0] = "cde";  
I have a function which takes the array name. 
function perform(array_name){
    array_name = eval(array_name);
    alert(array_name[0]);
}
perform("a_array");
perform("b_array");
perform("c_array");

Currently, I use eval() to do what I want. 
Is there any method not to use eval() here? 

A:

You can either pass the array itself:
function perform(array) {
    alert(array[0]);
}
perform(a_array);

Or access it over this:
function perform(array_name) {
    alert(this[array_name][0]);
}
perform('a_array');

A:

Instead of picking an array by eval'ing its name, store your arrays in an object:
all_arrays = {a:['abc'], b:['bcd'], c:['cde']};
function perform(array_name) {
    alert(all_arrays[array_name][0]);
}

