I want to change the speed of steinterval() while running I tried something like this:
inteval = 1;
setInterval(function(){
}, interval);
interval = 2;
Then I tried this which doesn't use intervals, but seems to work fine:
// Time
inteval = 1;
function refresh() {
setTimeout(function() {refresh()},interval);
}
refresh();
interval = 2;
I would rather have used setinterval() but this approach works fine. However in another similar question there is a longer approach: Changing the interval of SetInterval while it's running
If my snippet good in terms of efficiency? Is there a more efficient approach?