You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,40 +106,40 @@ Pentru browsere, temporizatoarele sunt descrise în [secțiunea timers](https://
106
106
107
107
## setInterval
108
108
109
-
The`setInterval`method has the same syntax as`setTimeout`:
109
+
Metoda`setInterval`are aceeași sintaxă ca și`setTimeout`:
110
110
111
111
```js
112
-
let timerId =setInterval(func|code, [delay], [arg1], [arg2], ...)
112
+
let timerId =setInterval(func|cod, [întârziere], [arg1], [arg2], ...)
113
113
```
114
114
115
-
All arguments have the same meaning. But unlike `setTimeout`it runs the function not only once, but regularly after the given interval of time.
115
+
Toate argumentele au aceeași semnificație. Dar spre deosebire de `setTimeout`acesta rulează funcția nu doar o singură dată, ci în mod regulat după intervalul de timp dat.
116
116
117
-
To stop further calls, we should call`clearInterval(timerId)`.
117
+
Pentru a opri apelurile ulterioare, ar trebui să apelăm`clearInterval(timerId)`.
118
118
119
-
The following example will show the message every 2 seconds. After 5 seconds, the output is stopped:
119
+
Următorul exemplu va afișa mesajul la fiecare 2 secunde. După 5 secunde, ieșirea este oprită:
120
120
121
121
```js run
122
-
//repeat with the interval of 2 seconds
123
-
let timerId =setInterval(() =>alert('tick'), 2000);
122
+
//se repetă cu intervalul de 2 secunde
123
+
let timerId =setInterval(() =>alert('tic'), 2000);
```smart header="Time goes on while `alert` is shown"
130
-
In most browsers, including Chrome and Firefox the internal timer continues "ticking" while showing`alert/confirm/prompt`.
129
+
```smart header="Timpul continuă cât este afișat `alert`"
130
+
În majoritatea browserelor, inclusiv Chrome și Firefox, cronometrul intern continuă să "ticăie" în timp ce se afișează`alert/confirm/prompt`.
131
131
132
-
So if you run the code above and don't dismiss the`alert`window for some time, then the next `alert`will be shown immediately as you do it. The actual interval between alerts will be shorter than 2 seconds.
132
+
Deci dacă executați codul de mai sus și nu închideți fereastra`alert`pentru o perioadă de timp, atunci următorul `alert`va fi afișat imediat ce o faceți. Intervalul real dintre alerte va fi mai scurt de 2 secunde.
133
133
```
134
134
135
-
## Nested setTimeout
135
+
## setTimeout inbricat
136
136
137
-
There are two ways of running something regularly.
137
+
Există două modalități de a rula ceva în mod regulat.
138
138
139
-
One is `setInterval`. The other one is a nested `setTimeout`, like this:
139
+
Una dintre ele este `setInterval`. Cealaltă este un `setTimeout` imbricate, ca acesta:
140
140
141
141
```js
142
-
/** instead of:
142
+
/** în loc de:
143
143
let timerId = setInterval(() => alert('tick'), 2000);
144
144
*/
145
145
@@ -151,11 +151,11 @@ let timerId = setTimeout(function tick() {
151
151
}, 2000);
152
152
```
153
153
154
-
The `setTimeout`above schedules the next call right at the end of the current one`(*)`.
154
+
`setTimeout`de mai sus planifică următorul apel chiar la sfârșitul celui curent`(*)`.
155
155
156
-
The nested`setTimeout`is a more flexible method than `setInterval`. This way the next call may be scheduled differently, depending on the results of the current one.
156
+
Metoda imbricată`setTimeout`este mai flexibilă decât `setInterval`. În acest fel următorul apel poate fi planificat diferit, în funcție de rezultatele apelului curent.
157
157
158
-
For instance, we need to write a service that sends a request to the server every 5 seconds asking for data, but in case the server is overloaded, it should increase the interval to 10, 20, 40 seconds...
158
+
De exemplu, trebuie să scriem un serviciu care să trimită o solicitare către server la fiecare 5 secunde pentru a cere date, dar în cazul în care serverul este supraîncărcat, ar trebui să crească intervalul la 10, 20, 40 de secunde...
0 commit comments