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 f71d8ce

Browse files
committed
UPDATE
1 parent 4621216 commit f71d8ce

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

‎JS/JS-br.md‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,9 @@ 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
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 aparece a partir da stack de chamadas? Porque as variáveis na função A são guardadas na pilha nesse momento. O motor atual do JS consegue indentificar quais variáveis precisam ser salvas na heap e quais precisam ser salvas na stack por análise de fuga.
368368

369-
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.
370-
371-
A classic interview question is using closures in loops to solve the problem of using `var` to define functions:
369+
Uma pergunta classica de entrevista é usando closure em loops para resolver o problema de usar `var` para definir funções:
372370

373371
```js
374372
for ( var i=1; i<=5; i++) {
@@ -378,9 +376,9 @@ for ( var i=1; i<=5; i++) {
378376
)
379377
```
380378
381-
First of all, all loops will be executed completely because `setTimeout` is an asynchronous function, and at that time `i` is 6, so it will print a bunch of 6.
379+
Em primeirio lugar, todos os loops vão ser executados completamente porque `setTimeout` é uma função assíncrona, e nesse momento `i` é 6, então isso vai exibir um bando de 6.
382380
383-
There are three solutions,closure is the first one:
381+
Existe três soluções, closure é a primeira:
384382
385383
```js
386384
for (var i = 1; i <= 5; i++) {
@@ -392,7 +390,7 @@ for (var i = 1; i <= 5; i++) {
392390
}
393391
```
394392
395-
The second one is to make use of the third parameter of `setTimeout`:
393+
A segunda é fazer o uso do terceiro parâmetro do `setTimeout`:
396394
397395
```js
398396
for ( var i=1; i<=5; i++) {
@@ -402,7 +400,7 @@ for ( var i=1; i<=5; i++) {
402400
}
403401
```
404402
405-
The third is to define `i` using `let`:
403+
A terceira é definir o `i` usando `let`:
406404
407405
```js
408406
for ( let i=1; i<=5; i++) {
@@ -412,11 +410,11 @@ for ( let i=1; i<=5; i++) {
412410
}
413411
```
414412
415-
For `let`, it will create a block-level scope, which is equivalent to:
413+
Para `let`, ele vai criar um escopo de block-level, do qual é equivalente a:
416414
417415
```js
418416
{
419-
// Form block-level scope
417+
// Forma o escopo block-level
420418
let i = 0
421419
{
422420
let ii = i

0 commit comments

Comments
(0)

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