Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4621216

Browse files
committed
Initialized Closure translation
1 parent 5fe3909 commit 4621216

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎JS/JS-br.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Usando `var` é mais provável error-prone, portanto ES6 introduziu uma nova pal
352352

353353
# Closure
354354

355-
The definition of closure is simple: function A returns a function B, and function B can access variables of function A, thus function B is called a closure.
355+
A definição de closure é simples: a função A retorna a função B, e a função b consegue acessar as variáveis da função A, portanto a função B é chamada de closure.
356356

357357
```js
358358
function A() {
@@ -364,6 +364,8 @@ function A() {
364364
}
365365
```
366366

367+
Se você estiver se perguntando por que a função B também consegue se referenciar as variáveis da função A enquanto a função A
368+
367369
Are you wondering why function B can also refer to variables in function A while function A has been popped up from the call stack? Because variables in function A are stored on the heap at this time. The current JS engine can identify which variables need to be stored on the heap and which need to be stored on the stack by escape analysis.
368370

369371
A classic interview question is using closures in loops to solve the problem of using `var` to define functions:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /