Skip to content

Commit 0a894c1

Browse files
committed
Stored the biggest timeout ID to avoid infinite loop.
1 parent 53decce commit 0a894c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/en/other/timeouts.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ it is necessary to use brute force in order to achieve this functionality.
9797
But there might still be timeouts that are unaffected by this arbitrary number. Another way of doing this is to consider that the ID given to a timeout is incremented by one everytime you call `setTimeout`.
9898

9999
// clear "all" timeouts
100-
for(var i = 1; i <= window.setTimeout(function(){}, 1); i++) {
100+
var biggestTimeoutId = window.setTimeout(function(){}, 1),
101+
i;
102+
for(i = 1; i <= biggestTimeoutId; i++) {
101103
clearTimeout(i);
102104
}
103105

0 commit comments

Comments
 (0)