-
Notifications
You must be signed in to change notification settings - Fork 101
Variable scope, closure #150
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 all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
02bb058
Translate a part of article
mahdiHash c804c16
Translate a part of article
mahdiHash 1da9b01
Translate some error messages
mahdiHash 8e30e70
Translate a part of article
mahdiHash a030eca
Translate a part of article
mahdiHash efb7c91
Translate a part of article
mahdiHash b420819
Translate a part of article
mahdiHash 645cfdc
Change some lines for better readability or understanding
mahdiHash 3b97485
Translate a part of article
mahdiHash d4a1f7d
Translate a part of article
mahdiHash 80f180f
Translate article
mahdiHash 67c299e
Translate task of "closure-latest-changes"
mahdiHash 328b3a9
Translate solution of "closure-latest-changes"
mahdiHash 1a91fdf
Translate task of "closure-variable-access"
mahdiHash c0360a3
Translate solution of "closure-variable-access"
mahdiHash 1698afa
Translate task of "counter-independent"
mahdiHash 539ffcf
Translate solution of "counter-independent"
mahdiHash 3f88e03
Translate task of "counter-object-independent"
mahdiHash 684a4d2
Translate task of "counter-object-independent"
mahdiHash c641e77
Translate task of "function-in-if"
mahdiHash 0654b5d
Translate solution of "function-in-if"
mahdiHash f8c0af6
Translate task of "closure-sum"
mahdiHash 6b9c591
Translate solution of "closure-sum"
mahdiHash 8dc9297
Translate task of "let-scope"
mahdiHash ef57382
Translate solution of "let-scope"
mahdiHash 26678cb
Change a comment for better readability
mahdiHash eb9f373
Translate task of "filter-through-function"
mahdiHash 53eaa4a
Translate task of "sort-by-field"
mahdiHash 5dfb504
Translate task of "make-army"
mahdiHash d22754e
Translate solution of "make-army"
mahdiHash b7290e2
Translate a word
mahdiHash d238e45
Add the deleted line
mahdiHash f973524
Remove the untranslated line
mahdiHash 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**. | ||
| جواب: **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
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` نداریم. |
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
6 changes: 3 additions & 3 deletions
6
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.