Skip to content

Commit 235a2ed

Browse files
committed
minor
1 parent 1733ef9 commit 235a2ed

File tree

1 file changed

+4
-4
lines changed
  • 1-js/06-advanced-functions/08-settimeout-setinterval

1 file changed

+4
-4
lines changed

1-js/06-advanced-functions/08-settimeout-setinterval/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ There's a side-effect. A function references the outer lexical environment, so,
239239

240240
There's a special use case: `setTimeout(func, 0)`, or just `setTimeout(func)`.
241241

242-
This schedules the execution of `func` as soon as possible. But the scheduler will invoke it only after the current code (i.e. the currently executing script) is complete.
242+
This schedules the execution of `func` as soon as possible. But the scheduler will invoke it only after the currently executing script is complete.
243243

244-
So the function is scheduled to run "right after" the current code.
244+
So the function is scheduled to run "right after" the current script.
245245

246246
For instance, this outputs "Hello", then immediately "World":
247247

@@ -251,7 +251,7 @@ setTimeout(() => alert("World"));
251251
alert("Hello");
252252
```
253253

254-
The first line "puts the call into calendar after 0ms". But the scheduler will only "check the calendar" after the current code is complete, so `"Hello"` is first, and `"World"` -- after it.
254+
The first line "puts the call into calendar after 0ms". But the scheduler will only "check the calendar" after the current script is complete, so `"Hello"` is first, and `"World"` -- after it.
255255

256256
There are also advanced browser-related use cases of zero-delay timeout, that we'll discuss in the chapter <info:event-loop>.
257257

@@ -289,7 +289,7 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
289289
- Methods `setTimeout(func, delay, ...args)` and `setInterval(func, delay, ...args)` allow us to run the `func` once/regularly after `delay` milliseconds.
290290
- To cancel the execution, we should call `clearTimeout/clearInterval` with the value returned by `setTimeout/setInterval`.
291291
- Nested `setTimeout` calls is a more flexible alternative to `setInterval`, allowing us to set the time *between* executions more precisely.
292-
- 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 (script) is complete".
292+
- 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 script is complete".
293293
- 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.
294294

295295
Please note that all scheduling methods do not *guarantee* the exact delay.

0 commit comments

Comments
 (0)