V
vunet.us
Is there a suggestion I can make this code run faster:
if(document.getElementById("1")){ doOne(); }
if(document.getElementById("2")){ doTwo(); }
....................
if(document.getElementById("n")){ doN(); }
It is a simplified version above. There is a large number of these
repetitive actions. So I wanted to change them for:
var arr = new Array("1","2","N");
for(var i=0;i<arr.length;i++){
switch(arr)
{
case "1": doOne();
case "2": doTwo();
case "N": doN();
}
}
But I doubt this will speed up, or will it? What would you suggest?
if(document.getElementById("1")){ doOne(); }
if(document.getElementById("2")){ doTwo(); }
....................
if(document.getElementById("n")){ doN(); }
It is a simplified version above. There is a large number of these
repetitive actions. So I wanted to change them for:
var arr = new Array("1","2","N");
for(var i=0;i<arr.length;i++){
switch(arr)
{
case "1": doOne();
case "2": doTwo();
case "N": doN();
}
}
But I doubt this will speed up, or will it? What would you suggest?