-
Notifications
You must be signed in to change notification settings - Fork 183
Variable scope, closure #219
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
Merged
Changes from 57 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
0cc7335
1-04-03: Garbage collection part 1
dolgachio 9becadb
1-04-03: Garbage Collection part 2
dolgachio 6b2daeb
1-04-03: Garbage Collection part 3
dolgachio 9ad7406
Update 1-js/04-object-basics/03-garbage-collection/article.md
tarasyyyk 9ce1a95
Update 1-js/04-object-basics/03-garbage-collection/article.md
tarasyyyk ba980b7
Merge branch 'master' of github.com:javascript-tutorial/uk.javascript…
dolgachio 74ad282
1-js/06-advanced-functions/03-closure: translate p. 1
dolgachio 076b1da
Merge branch 'master' of github.com:stas-dolgachov/uk.javascript.info
dolgachio 911cecd
1-js/06-advanced-functions/03-closure: translate p. 2
dolgachio cfdfb59
1-js/06-advanced-functions/03-closure: translate p. 3
dolgachio 1faad9d
1-js/06-advanced-functions/03-closure: transkate tasks
dolgachio 1304815
Merge branch 'javascript-tutorial:master' into master
dolgachio 784d79b
Update 1-js/06-advanced-functions/03-closure/1-closure-latest-changes…
dolgachio 742c311
Update 1-js/06-advanced-functions/03-closure/1-closure-latest-changes…
dolgachio 7ba32b0
Update 1-js/06-advanced-functions/03-closure/10-make-army/_js.view/so…
dolgachio 3ba3722
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 4212bd9
Update 1-js/06-advanced-functions/03-closure/3-counter-independent/so…
dolgachio c43b4b5
Update 1-js/06-advanced-functions/03-closure/10-make-army/_js.view/so…
dolgachio a21be02
Update 1-js/06-advanced-functions/03-closure/10-make-army/_js.view/so…
dolgachio e2e86d0
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio dd02f54
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio bf35432
Update 1-js/06-advanced-functions/03-closure/10-make-army/solution.md
dolgachio c721a91
Update 1-js/06-advanced-functions/03-closure/10-make-army/solution.md
dolgachio b7a7d7c
Update 1-js/06-advanced-functions/03-closure/10-make-army/solution.md
dolgachio d0f3a1e
Update 1-js/06-advanced-functions/03-closure/10-make-army/solution.md
dolgachio 7c7fbe6
Update 1-js/06-advanced-functions/03-closure/10-make-army/task.md
dolgachio a10f53c
Update 1-js/06-advanced-functions/03-closure/2-closure-variable-acces…
dolgachio bdfe39b
Update 1-js/06-advanced-functions/03-closure/3-counter-independent/ta…
dolgachio 871c5ad
Update 1-js/06-advanced-functions/03-closure/4-counter-object-indepen…
dolgachio 6d5980f
Update 1-js/06-advanced-functions/03-closure/6-closure-sum/task.md
dolgachio a8cbf1a
Update 1-js/06-advanced-functions/03-closure/7-let-scope/solution.md
dolgachio 5a6aa8b
Update 1-js/06-advanced-functions/03-closure/7-let-scope/solution.md
dolgachio 65611e5
Update 1-js/06-advanced-functions/03-closure/7-let-scope/solution.md
dolgachio 1c82c1b
Update 1-js/06-advanced-functions/03-closure/7-let-scope/solution.md
dolgachio 9c34751
Update 1-js/06-advanced-functions/03-closure/7-let-scope/task.md
dolgachio 9959f67
Update 1-js/06-advanced-functions/03-closure/8-filter-through-functio…
dolgachio 8b187b5
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/task.md
dolgachio 46e1841
Update 1-js/06-advanced-functions/03-closure/8-filter-through-functio…
dolgachio 1f60cdb
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/_js.view…
dolgachio 404e7c4
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/_js.view…
dolgachio 143e355
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/_js.view…
dolgachio 4fee958
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/_js.view…
dolgachio bb2fb19
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/task.md
dolgachio 79a696e
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/task.md
dolgachio 6c08021
Update 1-js/06-advanced-functions/03-closure/9-sort-by-field/task.md
dolgachio 9dd0815
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 2b538a3
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 21082c9
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio b7dca2c
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 33edfa4
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 75abb03
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 2ab537c
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 2f864c6
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio f73e73b
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 3a76506
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 6335aa3
Update 1-js/06-advanced-functions/03-closure/article.md
dolgachio 27db556
Revert image translation
dolgachio 75d356c
Update 1-js/06-advanced-functions/03-closure/2-closure-variable-acces…
tarasyyyk 1453e09
Update 1-js/06-advanced-functions/03-closure/2-closure-variable-acces…
tarasyyyk 8db01eb
Update task.md
tarasyyyk 7096c73
Update 1-js/06-advanced-functions/03-closure/2-closure-variable-acces…
tarasyyyk 5ab27d4
Update solution.md
tarasyyyk 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
6 changes: 3 additions & 3 deletions
6
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,5 @@ | ||
The answer is: **Pete**. | ||
Відповідь: **Петро**. | ||
|
||
A function gets outer variables as they are now, it uses the most recent values. | ||
Функція отримує зовнішні змінні такими, якими вони є зараз, тобто вона використовує останні значення. | ||
|
||
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
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
8 changes: 4 additions & 4 deletions
8
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,9 @@ | ||
The answer is: **Pete**. | ||
Відповідь: **Pete**. | ||
|
||
The `work()` function in the code below gets `name` from the place of its origin through the outer lexical environment reference: | ||
Функція `work()` в коді нижче отримує `name` від місця його походження через посилання на зовнішнє лексичне середовище: | ||
|
||
 | ||
|
||
So, the result is `"Pete"` here. | ||
Отже, відповіддю буде `"Pete"`. | ||
|
||
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"`. | ||
Але якби не було `let name` у `makeWorker()`, тоді пошук вийшов би за межі лексичного середовища та взяв би глобальну змінну, як ми бачимо з ланцюжка вище. В такому випадку відповідь була б `"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
6 changes: 3 additions & 3 deletions
6
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,5 @@ | ||
The answer: **0,1.** | ||
Відповідь: **0,1.** | ||
|
||
Functions `counter` and `counter2` are created by different invocations of `makeCounter`. | ||
Функції `counter` і `counter2` створюються різними викликами `makeCounter`. | ||
|
||
So they have independent outer Lexical Environments, each one has its own `count`. | ||
Отже, вони мають незалежні зовнішні лексичні середовища, кожне з яких має свою власну змінну `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
4 changes: 2 additions & 2 deletions
4
1-js/06-advanced-functions/03-closure/4-counter-object-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
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
4 changes: 2 additions & 2 deletions
4
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,3 @@ | ||
The result is **an error**. | ||
Результатом буде **помилка**. | ||
|
||
The function `sayHi` is declared inside the `if`, so it only lives inside it. There is no `sayHi` outside. | ||
Функція `sayHi` оголошується всередині `if`, тому вона доступна тільки всередині нього. Зовні функції `sayHi` не існує. |
8 changes: 4 additions & 4 deletions
8
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
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.