Skip to content

Commit 83a0401

Browse files
authored
Merge branch 'master' into 9-regular-expressions/14-regexp-lookahead-lookbehind/article.md-1
2 parents 5f6a4f0 + 562bbd9 commit 83a0401

File tree

9 files changed

+541
-535
lines changed

9 files changed

+541
-535
lines changed

1-js/02-first-steps/03-strict-mode/article.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,17 @@ alert("some code");
5353
5454
Иногда, когда `use strict` имеет значение, вы можете получить неправильные результаты.
5555
56-
Даже если мы нажмём `key:Shift+Enter` для ввода нескольких строк и напишем вверху `use strict` -- это не сработает. Это связано с тем, как консоль выполняет код внутри.
56+
Можно использовать `key:Shift+Enter` для ввода нескольких строк и написать вверху `use strict`:
5757
58-
Надёжный способ сделать так, чтобы `use strict` заработал, это ввести код в консоль следующим образом:
58+
```js
59+
'use strict'; <Shift+Enter для перехода на новую строку>
60+
// ...ваш код...
61+
<Enter для запуска>
62+
```
63+
64+
В большинстве браузеров, включая Chrome и Firefox, это работает.
65+
66+
В старых браузерах консоль не учитывает такой `use strict`, там можно "оборачивать" код в функцию, вот так:
5967

6068
```js
6169
(function() {

1-js/03-code-quality/04-ninja-code/article.md

Lines changed: 120 additions & 123 deletions
Large diffs are not rendered by default.

1-js/06-advanced-functions/11-currying-partials/1-ask-currying/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22

3-
1. Either use a wrapper function, an arrow to be concise:
3+
1. Либо для краткости используйте стрелочную функцию-обёртку:
44

55
```js
66
askPassword(() => user.login(true), () => user.login(false));
77
```
88

9-
Now it gets `user` from outer variables and runs it the normal way.
9+
Теперь `user` берётся из внешних переменных, и всё выполняется правильно.
1010

11-
2. Or create a partial function from `user.login` that uses `user` as the context and has the correct first argument:
11+
2. Либо сделайте из `user.login` функцию частичного применения, которая использует `user` как контекст, и которой передан корректный первый аргумент:
1212

1313

1414
```js

1-js/06-advanced-functions/11-currying-partials/1-ask-currying/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Partial application for login
5+
# Частичное применение для логина
66

7-
The task is a little more complex variant of <info:task/question-use-bind>.
7+
Эта задача -- немного более усложнённый вариант <info:task/question-use-bind>.
88

9-
The `user` object was modified. Now instead of two functions `loginOk/loginFail`, it has a single function `user.login(true/false)`.
9+
Объект `user` был изменён. Теперь вместо двух функций `loginOk/loginFail`, у него одна функция: `user.login(true/false)`.
1010

11-
What to pass `askPassword` in the code below, so that it calls `user.login(true)` as `ok` and `user.login(false)` as `fail`?
11+
Что нужно передать функции `askPassword` в коде ниже, чтобы она вызывала `user.login(true)` как `ok` и `user.login(false)` как `fail`?
1212

1313
```js
1414
function askPassword(ok, fail) {
@@ -30,5 +30,5 @@ askPassword(?, ?); // ?
3030
*/!*
3131
```
3232
33-
Your changes should only modify the highlighted fragment.
33+
Вы можете изменять только подсвеченные фрагменты кода.
3434

1-js/06-advanced-functions/11-currying-partials/article.md

Lines changed: 92 additions & 92 deletions
Large diffs are not rendered by default.

2-ui/1-document/08-styles-and-classes/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ So we can operate both on the full class string using `className` or on individu
6666
Methods of `classList`:
6767

6868
- `elem.classList.add/remove("class")` -- adds/removes the class.
69-
- `elem.classList.toggle("class")` -- if the class exists, then removes it, otherwise adds it.
69+
- `elem.classList.toggle("class")` -- adds the class if it doesn't exist, otherwise removes it.
7070
- `elem.classList.contains("class")` -- returns `true/false`, checks for the given class.
7171

72-
Besides that, `classList` is iterable, so we can list all classes like this:
72+
Besides, `classList` is iterable, so we can list all classes with `for..of`, like this:
7373

7474
```html run
7575
<body class="main page">
@@ -147,7 +147,7 @@ To set the full style as a string, there's a special property `style.cssText`:
147147
</script>
148148
```
149149

150-
We rarely use it, because such assignment removes all existing styles: it does not add, but replaces them. May occasionally delete something needed. But still can be done for new elements when we know we won't delete something important.
150+
This property is rarely used, because such assignment removes all existing styles: it does not add, but replaces them. May occasionally delete something needed. But we can safely use it for new elements, when we know we won't delete an existing style.
151151

152152
The same can be accomplished by setting an attribute: `div.setAttribute('style', 'color: red...')`.
153153
````

2-ui/5-loading/02-script-async-defer/article.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,13 @@ loadScript("/article/script-async-defer/small.js");
188188
| `defer` | *Порядок документа* (как расположены в документе). | Выполняется после того, как документ загружен и обработан (ждёт), непосредственно перед `DOMContentLoaded`. |
189189

190190
```warn header="Страница без скриптов должна быть рабочей"
191-
Пожалуйста, помните, что когда вы используете `defer`, страница видна до того, как скрипт загрузится и подключит все графические компоненты.
191+
Пожалуйста, помните, что когда вы используете `defer`, страница видна до того, как скрипт загрузится.
192192
193-
Поэтому кнопки должны быть отключены с помощью CSS или другим образом.
193+
Пользователь может знакомиться с содержимым страницы, читать её, но графические компоненты пока отключены.
194194
195-
На практике `defer` используется для скриптов, которым требуется доступ ко всему DOM и/или важен их относительный порядок выполнения.
195+
Поэтому обязательно должна быть индикация загрузки, нерабочие кнопки - отключены с помощью CSS или другим образом. Чтобы пользователь явно видел, что уже готово, а что пока нет.
196+
```
196197

198+
На практике `defer` используется для скриптов, которым требуется доступ ко всему DOM и/или важен их относительный порядок выполнения.
197199

198-
А `async` используется для независимых скриптов, например счётчиков и рекламы, относительный порядок выполнения которых не играет роли.
200+
А `async` хорош для независимых скриптов, например счётчиков и рекламы, относительный порядок выполнения которых не играет роли.

0 commit comments

Comments
 (0)