If you are doing this in the browser, one possible solution would be to do:
function setArray(a, b, c){
window['Array' + a][b] = c;
}
setArray('Top', 5, 100);
I would recommend that all your array's be contained in some object and not pollute the global namespace. So it would be more like:
var arrays = {
ArrayTop: [],
ArrayNorth: []
};
function setArray(a, b, c){
arrays['Array' + a][b] = c;
}
setArray('Top', 5, 100);
I would not recommend using eval. Eval is not meant for this kind of dynamic evaluation and it is a huge performance hit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…