Skip to content

Commit 4445548

Browse files
authored
Merge branch 'master' into master
2 parents abf39f4 + 82e7fc9 commit 4445548

File tree

35 files changed

+376
-375
lines changed

35 files changed

+376
-375
lines changed

1-js/01-getting-started/1-intro/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Let's see what's so special about JavaScript, what we can achieve with it, and w
66

77
*JavaScript* was initially created to *"make web pages alive"*.
88

9-
The programs in this language are called *scripts*. They can be written right in a web page's HTML and executed automatically as the page loads.
9+
The programs in this language are called *scripts*. They can be written right in a web page's HTML and run automatically as the page loads.
1010

1111
Scripts are provided and executed as plain text. They don't need special preparation or compilation to run.
1212

@@ -70,7 +70,7 @@ Examples of such restrictions include:
7070
There are ways to interact with camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency).
7171
- Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites (from a different domain, protocol or port).
7272

73-
This is called the "Same Origin Policy". To work around that, *both pages* must contain a special JavaScript code that handles data exchange.
73+
This is called the "Same Origin Policy". To work around that, *both pages* must agree for data exchange and contain a special JavaScript code that handles it. We'll cover that in the tutorial.
7474

7575
This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL `http://gmail.com` and steal information from there.
7676
- JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.

1-js/02-first-steps/05-types/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ The last three lines may need additional explanation:
226226

227227
## Summary
228228

229-
There are 7 basic types in JavaScript.
229+
There are 7 basic data types in JavaScript.
230230

231231
- `number` for numbers of any kind: integer or floating-point.
232232
- `string` for strings. A string may have one or more characters, there's no separate single-character type.

1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/solution.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
JavaScript-code:
1+
JavaScript-код:
22

33
```js demo run
4-
let name = prompt("What is your name?", "");
4+
let name = prompt("Ваше имя?", "");
55
alert(name);
66
```
77

8-
The full page:
8+
Вся страница:
99

1010
```html
1111
<!DOCTYPE html>
@@ -15,7 +15,7 @@ The full page:
1515
<script>
1616
'use strict';
1717
18-
let name = prompt("What is your name?", "");
18+
let name = prompt("Ваше имя?", "");
1919
alert(name);
2020
</script>
2121

1-js/02-first-steps/09-alert-prompt-confirm/1-simple-page/task.md

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

33
---
44

5-
# A simple page
5+
# Простая страница
66

7-
Create a web-page that asks for a name and outputs it.
7+
Создайте страницу, которая спрашивает имя у пользователя и выводит его.
88

99
[demo]
Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,110 @@
1-
# Interaction: alert, prompt, confirm
1+
# Взаимодействие: alert, prompt, confirm
22

3-
This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks.
3+
В этой части учебника мы разбираем "собственно JavaScript", без привязки к браузеру или другой среде выполнения.
4+
5+
Но, так как мы будем использовать браузер как демо-среду, нам нужно познакомиться по крайней мере с несколькими функциями его пользовательского интерфейса, а именно: `alert`, `prompt` и `confirm`.
46

5-
But we'll still be using the browser as our demo environment, so we should know at least a few of its user-interface functions. In this chapter, we'll get familiar with the browser functions `alert`, `prompt` and `confirm`.
67

78
## alert
89

9-
Syntax:
10+
Синтаксис:
1011

1112
```js
1213
alert(message);
1314
```
1415

15-
This shows a message and pauses script execution until the user presses "OK".
16+
Этот код отобразит окно в браузере и приостановит дальнейшее выполнение скриптов, до тех пор пока пользователь не нажмет кнопку "OK".
1617

17-
For example:
18+
Например:
1819

1920
```js run
2021
alert("Hello");
2122
```
2223

23-
The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc. until they have dealt with the window. In this case -- until they press "OK".
24+
Это небольшое окно с сообщением называется *модальным окном*. Понятие *модальный* означает, что пользователь не может взаимодействовать с интерфейсом остальной части страницы, нажимать на другие кнопки и т.д. до тех пор, пока взаимодействует с окном. В данном случае -- пока не будет нажата кнопка "OK".
2425

2526
## prompt
2627

27-
The function `prompt` accepts two arguments:
28+
Функция `prompt` принимает два аргумента:
2829

2930
```js no-beautify
3031
result = prompt(title, [default]);
3132
```
3233

33-
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/CANCEL.
34+
Этот код отобразит модальное окно с текстом, полем для ввода текста и кнопками OK/CANCEL.
3435

3536
`title`
36-
: The text to show the visitor.
37+
: Текст для отображения в окне.
3738

3839
`default`
39-
: An optional second parameter, the initial value for the input field.
40+
: Необязательный второй параметр, который устанавливает начальное значение в поле для текста в окне.
4041

41-
The visitor may type something in the prompt input field and press OK. Or they can cancel the input by pressing CANCEL or hitting the `key:Esc` key.
42+
Пользователь может напечатать что-либо в поле ввода и нажать OK. Или отменить ввод нажатием на кнопку CANCEL или нажав клавишу `key:Esc`.
4243

43-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
44+
Вызов `prompt` вернет текст, указанный в поле для ввода, или `null` если ввод отменен пользователем.
4445

45-
For instance:
46+
Например:
4647

4748
```js run
48-
let age = prompt('How old are you?', 100);
49+
let age = prompt('Сколько тебе лет?', 100);
4950

50-
alert(`You are ${age} years old!`); // You are 100 years old!
51+
alert(`Тебе ${age} лет!`); // Тебе 100 лет!
5152
```
5253

53-
````warn header="In IE: always supply a `default`"
54-
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
54+
````warn header="Для IE: всегда устанавливайте значение по умолчанию"
55+
Второй параметр не обязательный, но если не указать его, то Internet Explorer установить значение `"undefined"` в поле для ввода.
5556
56-
Run this code in Internet Explorer to see:
57+
Запустите код в Internet Explorer и посмотрите на результат:
5758
5859
```js run
5960
let test = prompt("Test");
6061
```
6162
62-
So, for prompts to look good in IE, we recommend always providing the second argument:
63+
Чтобы `prompt` хорошо выглядел в IE, рекомендуется всегда указывать второй параметр:
6364
6465
```js run
65-
let test = prompt("Test", ''); // <-- for IE
66+
let test = prompt("Test", ''); // <-- для IE
6667
```
6768
````
6869

6970
## confirm
7071

71-
The syntax:
72+
Синтаксис:
7273

7374
```js
7475
result = confirm(question);
7576
```
7677

77-
The function `confirm` shows a modal window with a `question` and two buttons: OK and CANCEL.
78+
Функция `confirm` отображает модальное окно с текстом вопроса `question` и двумя кнопками: OK и CANCEL.
7879

79-
The result is `true` if OK is pressed and `false` otherwise.
80+
Результат `true`, если нажата кнопка OK. В других случаях `false`.
8081

81-
For example:
82+
Например:
8283

8384
```js run
84-
let isBoss = confirm("Are you the boss?");
85+
let isBoss = confirm("Ты тут главный?");
8586

86-
alert( isBoss ); // true if OK is pressed
87+
alert( isBoss ); // true если нажата OK
8788
```
8889

89-
## Summary
90+
## Итого
9091

91-
We covered 3 browser-specific functions to interact with visitors:
92+
Рассмотрели 3 функции браузера для взаимодействия с пользователем:
9293

9394
`alert`
94-
: shows a message.
95+
: показывает сообщение.
9596

9697
`prompt`
97-
: shows a message asking the user to input text. It returns the text or, if CANCEL or `key:Esc` is clicked, `null`.
98+
: показывает сообщение и запрашивает ввод текста от пользователя. Возвращает напечатанный текст в поле ввода или `null`, если были нажаты кнопки CANCEL или `key:Esc` с клавиатуры.
9899

99100
`confirm`
100-
: shows a message and waits for the user to press "OK" or "CANCEL". It returns `true` for OK and `false` for CANCEL/`key:Esc`.
101+
: показывает сообщение и ждет, пока пользователь нажмет OK или CANCEL. Возвращает `true`, если нажата OK и `false`, если нажаты кнопки CANCEL или `key:Esc` с клавиатуры.
101102

102-
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
103+
Все эти методы являются модальными: останавливают выполнение скриптов и не позволяют пользователю взаимодействовать с остальной частью страницы до тех пор, пока окно не будет закрыто.
103104

104-
There are two limitations shared by all the methods above:
105+
На все указанные методы распространяется два ограничения:
105106

106-
1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
107-
2. The exact look of the window also depends on the browser. We can't modify it.
107+
1. Расположение окон определяется браузером. Обычно окна находятся в центре.
108+
2. Визуальное отображение окон зависит от браузера и мы не можем изменит их вид.
108109

109-
That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
110+
Такова цена простоты. Есть другие способы показать более приятные глазу окна с богатым функционалом для взаимодействия с пользователем, но если "навороты" не имеют значения, то данные методы работают отлично.

1-js/02-first-steps/16-javascript-specials/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ More in: <info:variables> and <info:types>.
103103
We're using a browser as a working environment, so basic UI functions will be:
104104

105105
[`prompt(question, [default])`](mdn:api/Window/prompt)
106-
: Ask a `question`, and return either what the visitor entered or `null` if they pressed "cancel".
106+
: Ask a `question`, and return either what the visitor entered or `null` if they clicked "cancel".
107107

108108
[`confirm(question)`](mdn:api/Window/confirm)
109109
: Ask a `question` and suggest to choose between Ok and Cancel. The choice is returned as `true/false`.
@@ -161,7 +161,7 @@ Comparisons
161161

162162
Other comparisons convert to a number as well.
163163

164-
The strict equality operator `===` doesn't do the conversion: different types always mean different values for it, so:
164+
The strict equality operator `===` doesn't do the conversion: different types always mean different values for it.
165165

166166
Values `null` and `undefined` are special: they equal `==` each other and don't equal anything else.
167167

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11

2-
Try running it:
2+
Попробуйте запустить код:
33

44
```js run
5-
let str = "Hello";
5+
let str = "Привет";
66

77
str.test = 5; // (*)
88

9-
alert(str.test);
9+
alert(str.test);
1010
```
1111

12-
There may be two kinds of result:
13-
1. `undefined`
14-
2. An error.
12+
В зависимости от того, используете ли вы cтрогий режим (`use strict`) или нет, результат может быть:
13+
1. `undefined` (без strict)
14+
2. Ошибка (strict mode)
1515

16-
Why? Let's replay what's happening at line `(*)`:
16+
Почему? Давайте посмотрим что происходит в строке кода, отмеченной `(*)`:
1717

18-
1. When a property of `str` is accessed, a "wrapper object" is created.
19-
2. The operation with the property is carried out on it. So, the object gets the `test` property.
20-
3. The operation finishes and the "wrapper object" disappears.
18+
1. В момент обращения к свойству `str` создается "объект-обертка".
19+
2. В cтрогом режиме, попытка изменения этого объекта выдает ошибку.
20+
3. В стандартном режиме, операция продолжается, объект получает свойство `test`, но после этого "объект-обертка" удаляется.
2121

22-
So, on the last line, `str` has no trace of the property. A new wrapper object for every object operation on a string.
22+
Выходит, в стандартном режиме на последней линии `str` больше не имеет свойства `test`.
2323

24-
Some browsers though may decide to further limit the programmer and disallow to assign properties to primitives at all. That's why in practice we can also see errors at line `(*)`. It's a little bit farther from the specification though.
25-
26-
**This example clearly shows that primitives are not objects.**
27-
28-
They just can not store data.
29-
30-
All property/method operations are performed with the help of temporary objects.
24+
**Данный пример наглядно показывает, что примитивы не являются объектами.**
3125

26+
Они не могут хранить дополнительные данные.

1-js/05-data-types/01-primitives-methods/1-string-new-property/task.md

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

33
---
44

5-
# Can I add a string property?
5+
# Можно ли добавить свойство строке?
66

77

8-
Consider the following code:
8+
Взгляните на следующий код:
99

1010
```js
11-
let str = "Hello";
11+
let str = "Привет";
1212

1313
str.test = 5;
1414

1515
alert(str.test);
1616
```
1717

18-
How do you think, will it work? What will be shown?
18+
Как вы думаете, это сработает? Что выведется на экран?

0 commit comments

Comments
 (0)