clearTimeout
will just prevent the function from being called again. It should not prevent any actions taken within. With that said, clearTimeout
does not seem very useful in your case. It looks like you chain the setTimeout
calls one after the other, and in this case clearTimeout
is useless because when you enter the function the timeout is already cleared.
In your case I would suggest using setInterval
instead of setTimeout
, and call clearInterval
to interrupt the function calls.