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
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,32 +77,32 @@ setTimeout(sayHi(), 1000);
77
77
Asta nu va funcționa, deoarece `setTimeout` se așteaptă la o referință spre o funcție. Iar aici `sayHi()` rulează funcția, iar *rezultatul execuției sale* este trecut la `setTimeout`. În cazul nostru, rezultatul lui `sayHi()` este `undefined` (funcția nu returnează nimic), deci nu se planifică nimic.
78
78
````
79
79
80
-
### Canceling with clearTimeout
80
+
### Anulare cu clearTimeout
81
81
82
-
A call to`setTimeout`returns a "timer identifier" `timerId`that we can use to cancel the execution.
82
+
Un apel la`setTimeout`returnează un "identificator de temporizator" `timerId`pe care îl putem folosi pentru a anula execuția.
83
83
84
-
The syntax to cancel:
84
+
Sintaxa de anulare:
85
85
86
86
```js
87
87
let timerId =setTimeout(...);
88
88
clearTimeout(timerId);
89
89
```
90
90
91
-
In the code below, we schedule the function and then cancel it (changed our mind). As a result, nothing happens:
91
+
În codul de mai jos, planificăm funcția și apoi o anulăm (ne-am răzgândit). Ca urmare, nu se întâmplă nimic:
92
92
93
93
```js run no-beautify
94
-
let timerId =setTimeout(() =>alert("never happens"), 1000);
95
-
alert(timerId); //timer identifier
94
+
let timerId =setTimeout(() =>alert("nu se întâmplă niciodată"), 1000);
alert(timerId); //same identifier (doesn't become null after canceling)
98
+
alert(timerId); //același identificator (nu devine nul după anulare)
99
99
```
100
100
101
-
As we can see from `alert` output, in a browser the timer identifier is a number. In other environments, this can be something else. For instance, Node.js returns a timer object with additional methods.
101
+
După cum se poate observa din ieșirea `alert`, într-un browser identificatorul temporizatorului este un număr. În alte medii, acesta poate fi altceva. De exemplu, Node.js returnează un obiect timer cu metode suplimentare.
102
102
103
-
Again, there is no universal specification for these methods, so that's fine.
103
+
Din nou, nu există o specificație universală pentru aceste metode, așa că este în regulă.
104
104
105
-
For browsers, timers are described in the [timers section](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers)of HTML Living Standard.
105
+
Pentru browsere, temporizatoarele sunt descrise în [secțiunea timers](https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers)din HTML Living Standard.
0 commit comments