Typo - mistake in canceling interval function
This commit is contained in:
parent
7bfdc06adb
commit
a8ff59e3ba
1 changed files with 1 additions and 1 deletions
|
@ -233,7 +233,7 @@ When a function is passed in `setInterval/setTimeout`, an internal reference is
|
||||||
setTimeout(function() {...}, 100);
|
setTimeout(function() {...}, 100);
|
||||||
```
|
```
|
||||||
|
|
||||||
For `setInterval` the function stays in memory until `cancelInterval` is called.
|
For `setInterval` the function stays in memory until `clearInterval` is called.
|
||||||
|
|
||||||
There's a side-effect. A function references the outer lexical environment, so, while it lives, outer variables live too. They may take much more memory than the function itself. So when we don't need the scheduled function anymore, it's better to cancel it, even if it's very small.
|
There's a side-effect. A function references the outer lexical environment, so, while it lives, outer variables live too. They may take much more memory than the function itself. So when we don't need the scheduled function anymore, it's better to cancel it, even if it's very small.
|
||||||
````
|
````
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue