var a1 = setTimeout(function(){});
var a2 = setTimeout(function(){});
var a3 = setTimeout(function(){});
var a4 = setTimeout(function(){});
var a5 = setTimeout(function(){});
if(){
clearInterval(a1);
clearInterval(a2);
// etc..
}
If you had a many setTimeout
, and each of these starts with a variable called "a" + un número
, as you could identify all the variables that begin with ay then with a number, to put them into an array and go through them to apply the clearInterval
, instead of doing the clearInterval
to each of them (imagining that there are more than 50 variables would be very tedious).