Is there any way to clear setTimeout()
if it doesn't have an explicit ID?
The problem is I'm not allowed to change some code that already ran and set the timers without any handler.
Does JS set 'anonymous handlers' to them? Are these timers stored anywhere accessible? Can I get any of those properties (the function the timer is about to call? the time it'll be called?)
Nope, you can't without a reference. You could try something REALLY hacky (don't do this! it's just an illustration of hackyness) to clear all timeouts:
for(var i=0; i<100000; i++) clearTimeout(i);
but again that's not foolproof and well beyond hacky.
Solution? Fight be able to change the source, so you can do this properly - or see if you can override the function creating the timer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With