Skip to content

Commit 0e73223

Browse files
committed
translated until line 193
1 parent 71c40f5 commit 0e73223

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

1-js/06-advanced-functions/01-recursion/article.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,39 +100,39 @@ Profunzimea maximă de recursivitate este limitată de motorul JavaScript. Ne pu
100100

101101
Acest lucru limitează aplicarea recursivității, dar aceasta rămâne totuși foarte largă. Există multe sarcini în care modul recursiv de gândire oferă un cod mai simplu, mai ușor de întreținut.
102102

103-
## The execution context and stack
103+
## Execution context și stack
104104

105-
Now let's examine how recursive calls work. For that we'll look under the hood of functions.
105+
Acum să examinăm modul în care funcționează apelurile recursive. Pentru aceasta ne vom uita sub capota funcțiilor.
106106

107-
The information about the process of execution of a running function is stored in its *execution context*.
107+
Informațiile despre procesul de execuție a unei funcții în curs de execuție sunt stocate în *execution context* al acesteia.
108108

109-
The [execution context](https://tc39.github.io/ecma262/#sec-execution-contexts) is an internal data structure that contains details about the execution of a function: where the control flow is now, the current variables, the value of `this` (we don't use it here) and few other internal details.
109+
[Execution context](https://tc39.github.io/ecma262/#sec-execution-contexts) este o structură internă de date care conține detalii despre execuția unei funcții: unde se află acum fluxul de control, variabilele curente, valoarea lui `this` (nu o folosim aici) și alte câteva detalii interne.
110110

111-
One function call has exactly one execution context associated with it.
111+
Un apel de funcție are asociat exact un context de execuție.
112112

113-
When a function makes a nested call, the following happens:
113+
Atunci când o funcție face un apel nested, se întâmplă următoarele:
114114

115-
- The current function is paused.
116-
- The execution context associated with it is remembered in a special data structure called *execution context stack*.
117-
- The nested call executes.
118-
- After it ends, the old execution context is retrieved from the stack, and the outer function is resumed from where it stopped.
115+
- Funcția curentă este pusă pe pauză.
116+
- Contextul de execuție asociat acesteia este reținut într-o structură de date specială numită *execution context stack*.
117+
- Se execută apelul nested.
118+
- După ce se termină, vechiul context de execuție este regăsit din stack, iar funcția exterioară este reluată de unde s-a oprit.
119119

120-
Let's see what happens during the `pow(2, 3)` call.
120+
Să vedem ce se întâmplă în timpul apelului `pow(2, 3)`.
121121

122122
### pow(2, 3)
123123

124-
In the beginning of the call `pow(2, 3)` the execution context will store variables: `x = 2, n = 3`, the execution flow is at line `1` of the function.
124+
La începutul apelului `pow(2, 3)` contextul de execuție va stoca variabilele: `x = 2, n = 3`, fluxul de execuție se află la linia `1` a funcției.
125125

126-
We can sketch it as:
126+
Îl putem schița precum:
127127

128128
<ul class="function-execution-context-list">
129129
<li>
130-
<span class="function-execution-context">Context: { x: 2, n: 3, at line 1 }</span>
130+
<span class="function-execution-context">Context: { x: 2, n: 3, la linia 1 }</span>
131131
<span class="function-execution-context-call">pow(2, 3)</span>
132132
</li>
133133
</ul>
134134

135-
That's when the function starts to execute. The condition `n == 1` is falsy, so the flow continues into the second branch of `if`:
135+
Asta este când funcția începe să se execute. Condiția `n == 1` este falsy, așa că fluxul continuă în a doua ramură a lui `if`:
136136

137137
```js run
138138
function pow(x, n) {
@@ -149,48 +149,48 @@ alert( pow(2, 3) );
149149
```
150150

151151

152-
The variables are same, but the line changes, so the context is now:
152+
Variabilele sunt aceleași, dar linia se schimbă, deci contextul este acum:
153153

154154
<ul class="function-execution-context-list">
155155
<li>
156-
<span class="function-execution-context">Context: { x: 2, n: 3, at line 5 }</span>
156+
<span class="function-execution-context">Context: { x: 2, n: 3, la linia 5 }</span>
157157
<span class="function-execution-context-call">pow(2, 3)</span>
158158
</li>
159159
</ul>
160160

161-
To calculate `x * pow(x, n - 1)`, we need to make a subcall of `pow` with new arguments `pow(2, 2)`.
161+
Pentru a calcula `x * pow(x, n - 1)`, trebuie să facem un subapel la `pow` cu noi argumente `pow(2, 2)`.
162162

163163
### pow(2, 2)
164164

165-
To do a nested call, JavaScript remembers the current execution context in the *execution context stack*.
165+
Pentru a efectua un apel nested, JavaScript își amintește contextul de execuție curent în *execution context stack*.
166166

167-
Here we call the same function `pow`, but it absolutely doesn't matter. The process is the same for all functions:
167+
Aici apelăm aceeași funcție `pow`, dar acest lucru nu contează absolut deloc. Procesul este același pentru toate funcțiile:
168168

169-
1. The current context is "remembered" on top of the stack.
170-
2. The new context is created for the subcall.
171-
3. When the subcall is finished -- the previous context is popped from the stack, and its execution continues.
169+
1. Contextul curent este "reținut" deasupra stack-ului.
170+
2. Noul context este creat pentru subapelare.
171+
3. Când subapelul este terminat -- contextul anterior este săltat din stack, iar execuția sa continuă.
172172

173-
Here's the context stack when we entered the subcall `pow(2, 2)`:
173+
Acesta este context stack când am intrat în subapelul `pow(2, 2)`:
174174

175175
<ul class="function-execution-context-list">
176176
<li>
177-
<span class="function-execution-context">Context: { x: 2, n: 2, at line 1 }</span>
177+
<span class="function-execution-context">Context: { x: 2, n: 2, la linia 1 }</span>
178178
<span class="function-execution-context-call">pow(2, 2)</span>
179179
</li>
180180
<li>
181-
<span class="function-execution-context">Context: { x: 2, n: 3, at line 5 }</span>
181+
<span class="function-execution-context">Context: { x: 2, n: 3, la linia 5 }</span>
182182
<span class="function-execution-context-call">pow(2, 3)</span>
183183
</li>
184184
</ul>
185185

186-
The new current execution context is on top (and bold), and previous remembered contexts are below.
186+
Noul context de execuție curent este în partea de sus (cu caractere îngroșate), iar contextele memorate anterior sunt mai jos.
187187

188-
When we finish the subcall -- it is easy to resume the previous context, because it keeps both variables and the exact place of the code where it stopped.
188+
Când terminăm subapelul -- este ușor să reluăm contextul anterior, deoarece acesta păstrează atât variabilele cât și locul exact al codului în care s-a oprit.
189189

190190
```smart
191-
Here in the picture we use the word "line", as in our example there's only one subcall in line, but generally a single line of code may contain multiple subcalls, like `pow() + pow() + somethingElse(…)`.
191+
Aici în imagine folosim cuvântul "linie", deoarece în exemplul nostru există un singur subapel în linie, dar în general o singură linie de cod poate conține mai multe subapelări, cum ar fi `pow(...) + pow(...) + somethingElse(…)`.
192192
193-
So it would be more precise to say that the execution resumes "immediately after the subcall".
193+
Deci ar fi mai precis să spunem că execuția se reia "imediat după subapelare".
194194
```
195195

196196
### pow(2, 1)

0 commit comments

Comments
 (0)