Scheduling: setTimeout and setInterval by diogoosz · Pull Request #483 · javascript-tutorial/pt.javascript.info
Repository navigation
Scheduling: setTimeout and setInterval - #483
Merged
gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-settimeout-setinterval Nov 21, 2026
Merged
Scheduling: setTimeout and setInterval #483 gabifs merged 2 commits into javascript-tutorial:master from diogoosz:translate-settimeout-setinterval
Conversation
diogoosz commented Nov 9, 2026
Copy link Copy Markdown
Contributor
Tradução do artigo "Scheduling: setTimeout and setInterval" para o português, incluindo os exercícios.
Conforme comentado na #1 .
Translate "Scheduling: setTimeout and setInterval" article to Portuguese
ac58401
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>gabifs reviewed Nov 12, 2026
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
Outdated
| - O navegador limita o atraso mínimo para cinco ou mais chamadas aninhadas de `setTimeout` ou para `setInterval` ( depois da 5ª chamada) a 4ms. Isso é por motivos históricos . | ||
|
|
||
| Please note that all scheduling methods do not *guarantee* the exact delay . | ||
| Observe que todos os métodos de agendamento não *garantem* o atraso exato . |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
Outdated
| Existe um caso de uso especial : `setTimeout(func, 0)`, ou simplesmente `setTimeout(func)`. | ||
|
|
||
| This schedules the execution of `func` as soon as possible. But the scheduler will invoke it only after the currently executing script is complete . | ||
| Isso agenda a execução de `func` o quanto antes possível. Mas o agendador só vai chamá-la depois que o script em execução no momento terminar . |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
Outdated
| - Os métodos `setTimeout(func, delay, ...args)` e `setInterval(func, delay, ...args)` nos permitem rodar `func` uma vez/regularmente depois de `delay` milissegundos . | ||
| - Para cancelar a execução, devemos chamar `clearTimeout/clearInterval` com o valor retornado por `setTimeout/setInterval`. | ||
| - Chamadas de `setTimeout` aninhadas são uma alternativa mais flexível ao `setInterval`, nos permitindo definir o tempo *entre* as execuções com mais precisão . | ||
| - Agendamento com atraso zero usando `setTimeout(func, 0)` ( o mesmo que `setTimeout(func)`) é usado para agendar a chamada "o quanto antes possível, mas depois que o script atual terminar ". |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
Outdated
| No navegador, existe uma limitação de com que frequência timers aninhados podem rodar. O [HTML Living Standard](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers) diz : " depois de cinco timers aninhados, o intervalo é forçado a ser de pelo menos 4 milissegundos .". | ||
|
|
||
| Let's demonstrate what it means with the example below. The `setTimeout` call in it re-schedules itself with zero delay. Each call remembers the real time from the previous one in the `times` array. What do the real delays look like? Let's see : | ||
| Vamos demonstrar o que isso significa com o exemplo abaixo. A chamada `setTimeout` nele reagenda a si mesma com atraso zero. Cada chamada lembra o tempo real desde a anterior no array `times` . Como são os atrasos reais? Vamos ver : |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
Outdated
| A primeira linha "coloca a chamada no calendário depois de 0ms". Mas o agendador só vai "checar o calendário" depois que o script atual terminar, então `"Hello"` vem primeiro, e `"World"` -- depois dele . | ||
|
|
||
| There are also advanced browser-related use cases of zero-delay timeout, that we'll discuss in the chapter <info:event-loop>. | ||
| Também existem casos de uso mais avançados, relacionados a navegadores, de atraso zero, que vamos discutir no capítulo <info:event-loop>. |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/1-output-numbers-100ms/solution.md
| Observe que, nas duas soluções, há um atraso inicial antes da primeira exibição. A função é chamada pela primeira vez depois de `1000ms` . | ||
|
|
||
| If we also want the function to run immediately, then we can add an additional call on a separate line, like this : | ||
| Se também quisermos que a função rode imediatamente, podemos adicionar uma chamada extra numa linha separada, assim : |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/4-settimeout-result/task.md
Outdated
| setTimeout(() => alert(i), 100); // ? | ||
|
|
||
| // assume that the time to execute this function is >100ms | ||
| // assuma que o tempo para executar essa função é >100ms |
View reviewed changes
Comment thread 1-js/06-advanced-functions/08-settimeout-setinterval/4-settimeout-result/solution.md
Outdated
| setTimeout(() => alert(i), 100); // 100000000 | ||
|
|
||
| // assume that the time to execute this function is >100ms | ||
| // assuma que o tempo para executar essa função é >100ms |
Apply review feedback from @gabifs
9c37343
- Fix inverted meaning: "todos...não garantem" (implies some do) -> "nenhum...garante" - "o quanto antes possível" -> "o mais cedo possível" (mixed idiom, 2 occurrences) - Fix missing word: "casos de uso...de atraso zero" -> "casos de uso avançados do setTimeout com atraso zero" - Fix mismatch between text and code: the comment/text said each call stores the time "since the previous one", but the code computes elapsed time since the start (`Date.now() - start`) - Fix TDZ bug in 1-output-numbers-100ms/solution.md: when printNumbers(n, n) is called, go() reaches clearInterval(timerId) on its first (immediate) call, before `let timerId` is initialized; declare it before calling go() - Fix comment describing a for loop as "essa função" -> "este laço" (2 occurrences) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
diogoosz commented Nov 21, 2026
Copy link Copy Markdown
Contributor
Author
|
Obrigado, @gabifs ! Apliquei tudo: corrigi o sentido invertido ("nenhum...garante"), "o quanto antes possível"→"o mais cedo possível" (2x), corrigi a frase truncada sobre atraso zero, corrigi a divergência entre texto/código no exemplo de atraso mínimo ("desde a anterior"→"desde o início"), corrigi o bug de TDZ no |
b138a91
into
javascript-tutorial : master
Nov 21, 2026
1 check passed
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment