using Objects as a map you can do this quite easily:
var obj = {
a1 = a1,
a2 = a2,
an = an
};
var chosen = obj["a"+x];
Now chosen contains the ax variable.
This is my blog, if you do not like it: Tits or GTFO!
var obj = {
a1 = a1,
a2 = a2,
an = an
};
var chosen = obj["a"+x];
(function(){
var Object = Object;
})();
(function(){
Var Object = window.Object;
})();
(function(){
var O = Object;
})();
(function(Object){
})(Object);
<div id="randomid" >
$('div#randomid') // IDs are unique, so the div is unnecessary
$('div[id="randomid"]') // #id is faster
$('body #randomid') // slower, since we have to find body first
$('#randomid',context) // the context makes jQuery use Sizzle, which is slow!
$('#context #randomid') // see above
$('#context').find('#randomid') // Hell, no!
So stick with the nice and simple:$('#randomid').do(something)
if( !window.console){
window.console = {
log: window.alert
};
}
var cl = window.console ? console.log : function(){};
Array.prototype.inArray = function(arg){
return !!~this.indexOf(arg);
};