minor fixes

This commit is contained in:
Ilya Kantor 2019-07-04 22:21:34 +03:00
parent b1b66a3065
commit 8365ea7163
6 changed files with 22 additions and 22 deletions

View file

@ -31,7 +31,7 @@ alert(phrase); // Error, phrase is not defined
## "var" has no block scope
`var` variables are either function-wide or global, they are visible through blocks.
Variables, declared with `var`, are either function-wide or global. They are visible through blocks.
For instance:
@ -45,7 +45,7 @@ alert(test); // true, the variable lives after if
*/!*
```
`var` ignores code blocks, so we've got a global variable `test`.
As `var` ignores code blocks, we've got a global variable `test`.
If we used `let test` instead of `var test`, then the variable would only be visible inside `if`:

View file

@ -9,7 +9,6 @@ There are two methods for it:
These methods are not a part of JavaScript specification. But most environments have the internal scheduler and provide these methods. In particular, they are supported in all browsers and Node.js.
## setTimeout
The syntax:
@ -291,9 +290,9 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
- To cancel the execution, we should call `clearInterval/clearTimeout` with the value returned by `setInterval/setTimeout`.
- Nested `setTimeout` calls is a more flexible alternative to `setInterval`. Also they can guarantee the minimal time *between* the executions.
- Zero delay scheduling with `setTimeout(func, 0)` (the same as `setTimeout(func)`) is used to schedule the call "as soon as possible, but after the current code is complete".
- The browsere ensures that for five or more nested call of `setTimeout`, or for zero-delay `setInterval`, the real delay between calls is at least 4ms. That's for historical reasons.
- The browser limits the minimal delay for five or more nested call of `setTimeout` or for `setInterval` (after 5th call) to 4ms. That's for historical reasons.
Please note that all scheduling methods do not *guarantee* the exact delay. We should not rely on that in the scheduled code.
Please note that all scheduling methods do not *guarantee* the exact delay.
For example, the in-browser timer may slow down for a lot of reasons:
- The CPU is overloaded.