Skip to content

Commit e3991f5

Browse files
committed
translated until line 149
1 parent 3b652df commit e3991f5

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ De exemplu:
2929
{
3030
// face o treabă cu variabile locale care nu ar trebui să fie văzute în exterior
3131
32-
let message = "Salut"; // vizibil doar în acest bloc
32+
let message = "Bună ziua"; // vizibil doar în acest bloc
3333
34-
alert(message); // Salut
34+
alert(message); // Bună ziua
3535
}
3636
3737
alert(message); // Error: message is not defined
@@ -42,7 +42,7 @@ Putem folosi acest lucru pentru a izola o bucată de cod care își face propria
4242
```js run
4343
{
4444
// afișează mesajul
45-
let message = "Salut";
45+
let message = "Bună ziua";
4646
alert(message);
4747
}
4848

@@ -58,7 +58,7 @@ Vă rugăm să notați că, fără blocuri separate ar exista o eroare, dacă am
5858
5959
```js run
6060
// arată mesajul
61-
let message = "Salut";
61+
let message = "Bună ziua";
6262
alert(message);
6363
6464
// arată un alt mesaj
@@ -73,9 +73,9 @@ Pentru `if`, `for`, `while` și așa mai departe, variabilele declarate în `{..
7373

7474
```js run
7575
if (true) {
76-
let phrase = "Salut!";
76+
let phrase = "Bună ziua!";
7777

78-
alert(phrase); // Salut!
78+
alert(phrase); // Bună ziua!
7979
}
8080

8181
alert(phrase); // Error, no such variable!
@@ -98,33 +98,33 @@ alert(i); // Eroare, nu există o astfel de variabilă
9898

9999
Vizual, `let i` se află în afara lui `{...}`. Dar construcția `for` este specială aici: variabila, declarată în interiorul ei, este considerată parte a blocului.
100100

101-
## Nested functions
101+
## Funcții nested
102102

103-
A function is called "nested" when it is created inside another function.
103+
O funcție este numită "nested" atunci când este creată în interiorul altei funcții.
104104

105-
It is easily possible to do this with JavaScript.
105+
Acest lucru este posibil cu ușurință în JavaScript.
106106

107-
We can use it to organize our code, like this:
107+
Îl putem folosi pentru a ne organiza codul, astfel:
108108

109109
```js
110110
function sayHiBye(firstName, lastName) {
111111

112-
// helper nested function to use below
112+
// funcție helper nested de utilizat mai jos
113113
function getFullName() {
114114
return firstName + " " + lastName;
115115
}
116116

117-
alert( "Hello, " + getFullName() );
118-
alert( "Bye, " + getFullName() );
117+
alert( "Bună ziua, " + getFullName() );
118+
alert( "La revedere, " + getFullName() );
119119

120120
}
121121
```
122122

123-
Here the *nested* function `getFullName()` is made for convenience. It can access the outer variables and so can return the full name. Nested functions are quite common in JavaScript.
123+
Aici funcția *nested* `getFullName()` este făcută pentru conveniență. Aceasta poate accesa variabilele exterioare și astfel poate returna numele complet. Funcțiile nested sunt destul de frecvente în JavaScript.
124124

125-
What's much more interesting, a nested function can be returned: either as a property of a new object or as a result by itself. It can then be used somewhere else. No matter where, it still has access to the same outer variables.
125+
Ceea ce este mult mai interesant, o funcție nested poate fi returnată: fie ca o proprietate a unui nou obiect ori ca un rezultat de sine stătător. Acesta poate fi apoi utilizat în altă parte. Indiferent unde, aceasta are în continuare acces la aceleași variabile exterioare.
126126

127-
Below, `makeCounter` creates the "counter" function that returns the next number on each invocation:
127+
Mai jos, `makeCounter` creează funcția "counter" care returnează următorul număr la fiecare invocare:
128128

129129
```js run
130130
function makeCounter() {
@@ -142,11 +142,11 @@ alert( counter() ); // 1
142142
alert( counter() ); // 2
143143
```
144144

145-
Despite being simple, slightly modified variants of that code have practical uses, for instance, as a [random number generator](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) to generate random values for automated tests.
145+
În ciuda faptului că sunt simple, variantele ușor modificate ale acestui cod au utilizări practice, de exemplu, ca [generator de numere aleatoare](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) pentru a genera valori aleatoare pentru testele automate.
146146

147-
How does this work? If we create multiple counters, will they be independent? What's going on with the variables here?
147+
Cum funcționează acest lucru? Dacă vom crea mai multe counters, vor fi ele independente? Ce se întâmplă cu variabilele aici?
148148

149-
Understanding such things is great for the overall knowledge of JavaScript and beneficial for more complex scenarios. So let's go a bit in-depth.
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.
150150

151151
## Lexical Environment
152152

0 commit comments

Comments
 (0)