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/03-closure/article.md
+29-29Lines changed: 29 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,58 +148,58 @@ Cum funcționează acest lucru? Dacă vom crea mai multe counters, vor fi ele in
148
148
149
149
Înțelegerea unor astfel de lucruri este excelentă pentru cunoștințele generale despre JavaScript și benefică pentru scenarii mai complexe. Așadar haideți să aprofundăm puțin.
150
150
151
-
## Lexical Environment
151
+
## Mediu Lexical
152
152
153
-
```warn header="Here be dragons!"
154
-
The in-depth technical explanation lies ahead.
153
+
```warn header="Aici sunt dragoni!"
154
+
Explicația tehnică aprofundată se găsește în cele ce urmează.
155
155
156
-
As far as I'd like to avoid low-level language details, any understanding without them would be lacking and incomplete, so get ready.
156
+
În măsura în care aș dori să evit detaliile low-level ale limbajului, orice înțelegere fără ele ar fi insuficientă și incompletă, așa că pregătiți-vă.
157
157
```
158
158
159
-
For clarity, the explanation is split into multiple steps.
159
+
Pentru claritate, explicația este împărțită în mai mulți pași.
160
160
161
-
### Step 1. Variables
161
+
### Pasul 1. Variabile
162
162
163
-
In JavaScript, every running function, code block `{...}`, and the script as a whole have an internal (hidden) associated object known as the *Lexical Environment*.
163
+
În JavaScript, fiecare funcție care rulează, blocul de cod `{...}`, și scriptul ca întreg au un obiect intern (ascuns) asociat, cunoscut sub numele de *Mediu Lexical*.
164
164
165
-
The Lexical Environment object consists of two parts:
165
+
Obiectul Lexical Environment este constituit din două părți:
166
166
167
-
1.*Environment Record* -- an object that stores all local variables as its properties (and some other information like the value of`this`).
168
-
2.A reference to the *outer lexical environment*, the one associated with the outer code.
167
+
1.*Environment Record* -- un obiect care stochează toate variabilele locale ca proprietăți ale acestuia (și alte informații, cum ar fi valoarea lui`this`).
168
+
2.O referință la *mediul lexical extern*, cel asociat cu codul extern.
169
169
170
-
**A "variable" is just a property of the special internal object, `Environment Record`. "To get or change a variable" means "to get or change a property of that object".**
170
+
**O "variabilă" este doar o proprietate a obiectului intern special, `Environment Record`. "A obține sau a modifica o variabilă" înseamnă "a obține sau a modifica o proprietate a acelui obiect".**
171
171
172
-
In this simple code without functions, there is only one Lexical Environment:
172
+
În acest cod simplu fără funcții, există un singur Mediu Lexical:
This is the so-called *global* Lexical Environment, associated with the whole script.
176
+
Acesta este așa-numitul Mediu Lexical *global*, asociat cu întregul script.
177
177
178
-
On the picture above, the rectangle means Environment Record (variable store) and the arrow means the outer reference. The global Lexical Environment has no outer reference, that's why the arrow points to`null`.
178
+
În imaginea de mai sus, dreptunghiul reprezintă Environment Record (stocare de variabile) iar săgeata reprezintă referința exterioară. Mediul Lexical global nu are o referință externă, de aceea săgeata indică`null`.
179
179
180
-
As the code starts executing and goes on, the Lexical Environment changes.
180
+
Pe măsură ce codul începe să se execute și continuă, Mediul Lexical se modifică.
Rectangles on the right-hand side demonstrate how the global Lexical Environment changes during the execution:
186
+
Dreptunghiurile din partea dreaptă demonstrează cum se modifică Mediul Lexical global în timpul execuției:
187
187
188
-
1.When the script starts, the Lexical Environment is pre-populated with all declared variables.
189
-
-Initially, they are in the "Uninitialized" state. That's a special internal state, it means that the engine knows about the variable, but it cannot be referenced until it has been declared with`let`. It's almost the same as if the variable didn't exist.
190
-
2.Then `let phrase` definition appears. There's no assignment yet, so its value is`undefined`. We can use the variable from this point forward.
191
-
3.`phrase`is assigned a value.
192
-
4.`phrase`changes the value.
188
+
1.La pornirea scriptului, Mediul Lexical este prepopulat cu toate variabilele declarate.
189
+
-Inițial, acestea se află în starea "Uninitialized". Aceasta este o stare internă specială, ceea ce înseamnă că motorul știe despre variabilă, dar nu poate fi referențiată până când nu este declarată cu`let`. Este aproape la fel ca și cum variabila nu ar exista.
190
+
2.Apoi apare definiția `let phrase`. Nu există încă o atribuire, deci valoarea ei este`undefined`. Putem folosi variabila din acest punct încolo.
191
+
3.Lui `phrase`i se atribuie o valoare.
192
+
4.`phrase`își schimbă valoarea.
193
193
194
-
Everything looks simple for now, right?
194
+
Totul pare simplu deocamdată, nu?
195
195
196
-
-A variable is a property of a special internal object, associated with the currently executing block/function/script.
197
-
-Working with variables is actually working with the properties of that object.
196
+
-O variabilă este o proprietate a unui obiect intern special, asociată blocului/funcției/scriptului în curs de execuție.
197
+
-Lucrul cu variabilele înseamnă de fapt lucrul cu proprietățile acelui obiect.
198
198
199
-
```smart header="Lexical Environment is a specification object"
200
-
"Lexical Environment" is a specification object: it only exists "theoretically" in the [language specification](https://tc39.es/ecma262/#sec-lexical-environments) to describe how things work. We can't get this object in our code and manipulate it directly.
199
+
```smart header="Mediul Lexical este un obiect din specificație"
200
+
"Mediul Lexical" este un obiect din specificație: el există doar "teoretic" în [specificația limbajului](https://tc39.es/ecma262/#sec-lexical-environments) pentru a descrie modul în care funcționează lucrurile. Nu putem obține acest obiect în codul nostru și să-l manipulăm direct.
201
201
202
-
JavaScript engines also may optimize it, discard variables that are unused to save memory and perform other internal tricks, as long as the visible behavior remains as described.
202
+
De asemenea motoarele JavaScript îl pot optimiza, pot renunța la variabilele nefolosite pentru a economisi memorie și pot efectua alte trucuri interne, atâta timp cât comportamentul vizibil rămâne cel descris.
0 commit comments