-
Notifications
You must be signed in to change notification settings - Fork 231
Variable scope #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
EzequielCaste
merged 8 commits into
javascript-tutorial:master
from
vplentinax:variable-scope
Jun 22, 2020
Merged
Variable scope #178
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c4a2fc1
variable-scope
vplentinax 4170cb6
Merge branch 'master' into variable-scope
vplentinax 72947cc
Update 1-js/06-advanced-functions/03-closure/2-closure-variable-acces…
EzequielCaste b96f5ed
Update 1-js/06-advanced-functions/03-closure/6-closure-sum/task.md
EzequielCaste 1c85805
Update 1-js/06-advanced-functions/03-closure/8-filter-through-functio…
EzequielCaste 6b07130
Update 1-js/06-advanced-functions/03-closure/article.md
EzequielCaste 625f899
Update 1-js/06-advanced-functions/03-closure/article.md
EzequielCaste 84ff7f2
Update 1-js/06-advanced-functions/03-closure/6-closure-sum/task.md
EzequielCaste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 4 additions & 3 deletions
7
1-js/06-advanced-functions/03-closure/1-closure-latest-changes/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| The answer is: **Pete**. | ||
| La respuesta es: **Pete**. | ||
|
|
||
| A function gets outer variables as they are now, it uses the most recent values. | ||
| Una función obtiene variables externas con su estado actual, y utiliza los valores más recientes. | ||
|
|
||
| Los valores de variables anteriores no se guardan en ningún lado. Cuando una función quiere una variable, toma el valor actual de su propio entorno léxico o el externo. | ||
|
|
||
| Old variable values are not saved anywhere. When a function wants a variable, it takes the current value from its own Lexical Environment or the outer one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
1-js/06-advanced-functions/03-closure/2-closure-variable-access/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| The answer is: **Pete**. | ||
|
|
||
| The `work()` function in the code below gets `name` from the place of its origin through the outer lexical environment reference: | ||
| La respuesta es: **Pete**. | ||
|
|
||
| La función `work()` en el código a continuación obtiene `name` del lugar de su origen a través de la referencia del entorno léxico externo: | ||
|
|
||
|  | ||
|
|
||
| So, the result is `"Pete"` here. | ||
| Entonces, el resultado es "Pete". | ||
|
|
||
| Pero si no hubiera `let name` en` makeWorker () `, entonces la búsqueda saldría y tomaría la variable global como podemos ver en la cadena de arriba. En ese caso, el resultado sería `John`. | ||
|
|
||
| But if there were no `let name` in `makeWorker()`, then the search would go outside and take the global variable as we can see from the chain above. In that case the result would be `"John"`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
1-js/06-advanced-functions/03-closure/3-counter-independent/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| The answer: **0,1.** | ||
|
|
||
| Functions `counter` and `counter2` are created by different invocations of `makeCounter`. | ||
| La respuesta: **0,1.** | ||
|
|
||
| Las funciones `counter` y` counter2` son creadas por diferentes invocaciones de `makeCounter`. | ||
|
|
||
| Por lo tanto, tienen entornos léxicos externos independientes, cada uno tiene su propio `count`. | ||
|
|
||
| So they have independent outer Lexical Environments, each one has its own `count`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
1-js/06-advanced-functions/03-closure/5-function-in-if/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| The result is **an error**. | ||
|
|
||
| The function `sayHi` is declared inside the `if`, so it only lives inside it. There is no `sayHi` outside. | ||
| El resultado es **un error**. | ||
|
|
||
| La función `sayHi` se declara dentro de `if`, por lo que solo vive dentro de ella. No hay `sayHi` afuera. | ||
|
|
4 changes: 2 additions & 2 deletions
4
1-js/06-advanced-functions/03-closure/5-function-in-if/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
1-js/06-advanced-functions/03-closure/6-closure-sum/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.