If the functions are globally accessible you may write
window['a'+i]()
Otherwise, you may be able to rewrite your code to add all the functions to one variable:
var f = {
a1: function() { },
a2: function() { },
a3: function() { }
};
... and call f['a'+i]()
.
If you're rewriting, since all functions are named by an index, you might as well write:
var myFunctions = [
function() { },
function() { },
function() { }
];
... and call myFunctions[i]()
. (Of course, as Felix Kling points out in comments, i
here would have to be adjusted to be 0-based).