Skip to content

Commit 533707b

Browse files
committed
translated until line 365
1 parent 6d8df49 commit 533707b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

1-js/06-advanced-functions/03-closure/article.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,15 @@ Adică: ele își amintesc automat unde au fost create cu ajutorul unei propriet
310310
Atunci când, la un interviu, un dezvoltator frontend primește o întrebare despre "ce este un closure?", un răspuns valid ar fi o definiție a closure-ului și o explicație că toate funcțiile din JavaScript sunt closure-uri, și poate câteva cuvinte în plus despre detalii tehnice: proprietatea `[[Environment]]` și cum funcționează Mediile Lexicale.
311311
```
312312

313-
## Garbage collection
313+
## Colectarea gunoiului
314314

315-
Usually, a Lexical Environment is removed from memory with all the variables after the function call finishes. That's because there are no references to it. As any JavaScript object, it's only kept in memory while it's reachable.
315+
De obicei, un Mediu Lexical este eliminat din memorie împreună cu toate variabilele după ce se termină apelul funcției. Acest lucru se datorează faptului că nu mai există referințe la acesta. Ca orice obiect JavaScript, este păstrat în memorie doar atât timp cât este accesibil.
316316

317-
However, if there's a nested function that is still reachable after the end of a function, then it has `[[Environment]]` property that references the lexical environment.
317+
Cu toate acestea, dacă există o funcție imbricată care este încă accesibilă după terminarea unei funcții, atunci aceasta are proprietatea `[[Environment]]` care face referire la Mediul Lexical.
318318

319-
In that case the Lexical Environment is still reachable even after the completion of the function, so it stays alive.
319+
În acel caz Mediul Lexical este încă accesibil chiar și după terminarea funcției, deci rămâne în viață.
320320

321-
For example:
321+
De exemplu:
322322

323323
```js
324324
function f() {
@@ -329,11 +329,11 @@ function f() {
329329
}
330330
}
331331

332-
let g = f(); // g.[[Environment]] stores a reference to the Lexical Environment
333-
// of the corresponding f() call
332+
let g = f(); // g.[[Environment]] stochează o referință la Mediul Lexical
333+
// al apelului f() corespunzător
334334
```
335335

336-
Please note that if `f()` is called many times, and resulting functions are saved, then all corresponding Lexical Environment objects will also be retained in memory. In the code below, all 3 of them:
336+
Vă rugăm să notați că, dacă `f()` este apelat de multe ori, iar funcțiile rezultate sunt salvate, atunci toate obiectele corespunzătoare Mediului Lexical vor fi de asemenea păstrate în memorie. În codul de mai jos, toate cele 3:
337337

338338
```js
339339
function f() {
@@ -342,14 +342,14 @@ function f() {
342342
return function() { alert(value); };
343343
}
344344

345-
// 3 functions in array, every one of them links to Lexical Environment
346-
// from the corresponding f() run
345+
// 3 funcții în matrice, fiecare dintre ele are legătură cu Mediul Lexical
346+
// de la execuția corespunzătoare f()
347347
let arr = [f(), f(), f()];
348348
```
349349

350-
A Lexical Environment object dies when it becomes unreachable (just like any other object). In other words, it exists only while there's at least one nested function referencing it.
350+
Un obiect Lexical Environment moare atunci când devine inaccesibil (la fel ca orice alt obiect). Cu alte cuvinte, acesta există doar atât timp cât există cel puțin o funcție imbricată care face referire la el.
351351

352-
In the code below, after the nested function is removed, its enclosing Lexical Environment (and hence the `value`) is cleaned from memory:
352+
În codul de mai jos, după ce funcția imbricată este eliminată, Mediul Lexical care o înconjoară (și prin urmare `value`) este curățat din memorie:
353353

354354
```js
355355
function f() {
@@ -360,9 +360,9 @@ function f() {
360360
}
361361
}
362362

363-
let g = f(); // while g function exists, the value stays in memory
363+
let g = f(); // cât timp există funcția g, valoarea rămâne în memorie
364364

365-
g = null; // ...and now the memory is cleaned up
365+
g = null; // ...și acum memoria este curățată
366366
```
367367

368368
### Real-life optimizations

0 commit comments

Comments
 (0)