Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3
Variable scope, closure#165
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions1-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 @@ | ||
Odpověď zní: **Petr**. | ||
Funkce načítá vnější proměnné tak, jak vypadají právě v tuto chvíli. Používá poslední hodnoty. | ||
Staré hodnoty proměnných se nikam neukládají. Když funkce chce proměnnou, vezme její aktuální hodnotu ze svého vlastního lexikálního prostředí nebo z vnějšího. |
18 changes: 9 additions & 9 deletions1-js/06-advanced-functions/03-closure/1-closure-latest-changes/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
12 changes: 6 additions & 6 deletions1-js/06-advanced-functions/03-closure/10-make-army/_js.view/solution.js
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,13 +1,13 @@ | ||
functionvytvořArmádu() { | ||
letstřelci = []; | ||
for(let i = 0; i < 10; i++) { | ||
letstřelec = function() { //funkce střelec | ||
alert( i );//by měla zobrazit své číslo | ||
}; | ||
střelci.push(střelec); | ||
} | ||
returnstřelci; | ||
} |
20 changes: 10 additions & 10 deletions1-js/06-advanced-functions/03-closure/10-make-army/_js.view/source.js
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,22 +1,22 @@ | ||
functionvytvořArmádu() { | ||
letstřelci = []; | ||
let i = 0; | ||
while (i < 10) { | ||
letstřelec = function() { //funkce střelec | ||
alert( i );//by měla zobrazit své číslo | ||
}; | ||
střelci.push(střelec); | ||
i++; | ||
} | ||
returnstřelci; | ||
} | ||
/* | ||
letarmáda =vytvořArmádu(); | ||
armáda[0](); //střelec číslo 0 zobrazí 10 | ||
armáda[5](); //a číslo 5zobrazí také 10... | ||
// ...všichni střelci zobrazí 10místo svého čísla 0, 1, 2, 3... | ||
*/ |
14 changes: 7 additions & 7 deletions1-js/06-advanced-functions/03-closure/10-make-army/_js.view/test.js
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
91 changes: 45 additions & 46 deletions1-js/06-advanced-functions/03-closure/10-make-army/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
35 changes: 17 additions & 18 deletions1-js/06-advanced-functions/03-closure/10-make-army/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
8 changes: 4 additions & 4 deletions1-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 @@ | ||
Odpověď zní: **Petr**. | ||
Funkce `pracuj()`uvedená v následujícím kódu načte `jméno` z místa svého vzniku odkazem na vnější lexikální prostředí: | ||
 | ||
Výsledkem zde je tedy `"Petr"`. | ||
Kdyby však ve funkci `vytvořPracovníka()` nebylo `let jméno`,pak by hledání pokračovalo dál ven a převzalo globální proměnnou, jak vidíme v uvedeném řetězci. V tom případě by výsledek byl `"Jan"`. |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.