- Notifications
You must be signed in to change notification settings - Fork179
Reference Type#254
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
Reference Type#254
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
24 changes: 12 additions & 12 deletions1-js/99-js-misc/04-reference-type/2-check-syntax/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,37 +1,37 @@ | ||
**Помилка**! | ||
Спробуйте: | ||
```js run | ||
let user = { | ||
name: "Іван", | ||
go: function() { alert(this.name) } | ||
} | ||
(user.go)() //помилка! | ||
``` | ||
Повідомлення про помилку в більшості браузерів не дає нам велику кількість підказок про те, що пішло не так. | ||
**Помилка з'являється, оскільки крапка з комою відсутня після `user = {...}`.** | ||
JavaScriptне вставляэ автоматично крапку з комою перед дужками `(user.go)()` тому, що він читає код, як: | ||
```js no-beautify | ||
let user = { go:... }(user.go)() | ||
``` | ||
Тоді ми також можемо побачити, що такий спільний вираз синтаксично є викликом об'єкта`{ go: ... }`як функція з аргументом`(user.go)`.І це також відбувається на тій же лінії, з `let user`,тому, оскільки об'єкт`user`ще не визначений, виникає помилка. | ||
Якщо ми вставляємо крапку з комою, все добре: | ||
```js run | ||
let user = { | ||
name: "Іван", | ||
go: function() { alert(this.name) } | ||
}*!*;*/!* | ||
(user.go)() //Іван | ||
``` | ||
Зверніть увагу, що дужки навколо `(user.go)`нічого не роблять тут. Зазвичай вони встановлюють порядок операцій, але тут крапка спрацьовує спочатку в будь-якому випадку, тому немає ефекту. Тільки грає роль лише крапка з комою вкінці. |
8 changes: 4 additions & 4 deletions1-js/99-js-misc/04-reference-type/2-check-syntax/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
20 changes: 10 additions & 10 deletions1-js/99-js-misc/04-reference-type/3-why-this/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,22 +1,22 @@ | ||
Ось пояснення. | ||
1.Це звичайний виклик методу об'єкта. | ||
2.Те ж саме, дужки не змінюють порядок операцій тут, крапка спрацьовує спочатку в будь-якому випадку. | ||
3.Тут у нас є більш складний виклик `(вираз)()`.Виклик працює так, ніби він був розділений на два рядки: | ||
```js no-beautify | ||
f = obj.go; //обчислити вираз | ||
f(); //викликати те, що ми маємо | ||
``` | ||
Тут `f()`виконується як функція, без `this`. | ||
4.Ми маємо вираз подібну річ, як в`(3)`,ліворуч від дужок`()`. | ||
Щоб пояснити поведінку`(3)`та `(4)`, ми повинні нагадати, що аксесори властивостей (крапка або квадратні дужки) повертають значення посисального типу. | ||
Будь-яка операція на цьому, крім виклику методу (наприклад, присвоєння `=`або `||`)перетворює його в звичайне значення, яке не носить інформацію, яка дозволяє встановити `this`. | ||
6 changes: 3 additions & 3 deletions1-js/99-js-misc/04-reference-type/3-why-this/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
90 changes: 45 additions & 45 deletions1-js/99-js-misc/04-reference-type/article.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
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.