Skip to content

Commit 05b943c

Browse files
authored
Merge pull request #172 from javascript-tutorial/sync-285083fc
Sync with upstream @ 285083f
2 parents c279445 + 8008bd3 commit 05b943c

File tree

27 files changed

+149
-95
lines changed

27 files changed

+149
-95
lines changed

1-js/02-first-steps/04-variables/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,20 @@ let message = "That"; // SyntaxError: 'message' has already been declared
165165
Интересно е да бележим, че съществува [функционални](https://bg.wikipedia.org/wiki/%D0%A4%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%BE%D0%BD%D0%B0%D0%BB%D0%BD%D0%BE_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%B8%D1%80%D0%B0%D0%BD%D0%B5) програмни езици, като [Scala](http://www.scala-lang.org/) или [Erlang](http://www.erlang.org/), които забраняват промяната на стойностите на променливите.
166166
=======
167167
```smart header="Functional languages"
168+
<<<<<<< HEAD
168169
It's interesting to note that there exist [functional](https://en.wikipedia.org/wiki/Functional_programming) programming languages, like [Scala](https://www.scala-lang.org/) or [Erlang](https://www.erlang.org/) that forbid changing variable values.
169170
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
171+
=======
172+
It's interesting to note that there exist so-called [pure functional](https://en.wikipedia.org/wiki/Purely_functional_programming) programming languages, such as [Haskell](https://en.wikipedia.org/wiki/Haskell), that forbid changing variable values.
173+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
170174
171175
При такива езици, веднъж когато стойността е запазена "в кутията", то е завинаги там. Ако се наложи да запазим нещо друго, езика ни принуждава да създадем нова кутия (да декларираме нова променлива). Не можем да използваме старата.
172176
177+
<<<<<<< HEAD
173178
От пръв поглед може да ви се види малко странно, но тези езици са способни на доста сериозни разработки. Повече от това, има области като паралелни изчисления, където това ограничение носи определени ползи. Изучаване на подобен език (дори ако не планирате да го използвате скоро) се препоръчва, за да разширите знанията си.
179+
=======
180+
Though it may seem a little odd at first sight, these languages are quite capable of serious development. More than that, there are areas like parallel computations where this limitation confers certain benefits.
181+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
174182
```
175183

176184
## Именуване на променливи [#variable-naming]

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ alert(age); // "undefined"
239239
240240
`typeof` оператора връща типът, на даден аргумент. Той е полезен, когато искаме да обработим данни от различен тип, по различен начин или просто искаме да проверим типът на дадени данни.
241241
242+
<<<<<<< HEAD
242243
Оператора може да бъде използван по два начина:
244+
=======
245+
The `typeof` operator returns the type of the operand. It's useful when we want to process values of different types differently or just want to do a quick check.
246+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
243247

244248
<<<<<<< HEAD
245249
1. Като оператор: `typeof x`.

1-js/02-first-steps/07-type-conversions/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ alert(typeof value); // символен низ
3939

4040
## Преубразуване в число(number)
4141

42+
<<<<<<< HEAD
4243
Преобразуването в число се случва автоматично в математически функции и изрази.
44+
=======
45+
Numeric conversion in mathematical functions and expressions happens automatically.
46+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
4347
4448
Например, когато делене `/` се използва с нечислов тип:
4549

1-js/02-first-steps/08-operators/article.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@
5050
Например:
5151

5252
```js run
53+
<<<<<<< HEAD
5354
alert( 5 % 2 ); // 1, остатък от 5, разделен на 2
5455
alert( 8 % 3 ); // 2, остатък от 8, разделен на 3
56+
=======
57+
alert( 5 % 2 ); // 1, the remainder of 5 divided by 2
58+
alert( 8 % 3 ); // 2, the remainder of 8 divided by 3
59+
alert( 8 % 4 ); // 0, the remainder of 8 divided by 4
60+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
5561
```
5662

5763
### Степенуване **
@@ -68,7 +74,13 @@ alert( 2 ** 3 ); // 8 (2 * 2 * 2, 3 пъти)
6874
alert( 2 ** 4 ); // 16 (2 * 2 * 2 * 2, 4 пъти)
6975
```
7076

77+
<<<<<<< HEAD
7178
Математически, експоненцията е дефинирана и за нецелочислени числа. Например, квадратен корен е експоненция от `1/2`:
79+
=======
80+
Just like in maths, the exponentiation operator is defined for non-integer numbers as well.
81+
82+
For example, a square root is an exponentiation by ½:
83+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
7284

7385
```js run
7486
alert( 4 ** (1/2) ); // 2 (степен на 1/2 е същата като квадратен корен)
@@ -335,11 +347,15 @@ let n = 2;
335347
336348
n *= 3 + 5; // right part evaluated first, same as n *= 8
337349
350+
<<<<<<< HEAD
338351
<<<<<<< HEAD
339352
alert( n ); // 16 (дясната част се изчислява първо, същото като n *= 8)
340353
=======
341354
alert( n ); // 16
342355
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
356+
=======
357+
alert( n ); // 16
358+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
343359
```
344360

345361
## Увеличаване/Намаляване

1-js/02-first-steps/10-ifelse/article.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ if (cond) {
6868

6969
## Клаузата "else"
7070

71+
<<<<<<< HEAD
7172
Изразът `if` може да съдържа незадължителен блок `else`. Той се изпълнява, когато условието е невярно.
7273

7374
Например:
75+
=======
76+
The `if` statement may contain an optional `else` block. It executes when the condition is falsy.
77+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
7478
7579
```js run
7680
let year = prompt('Коя година са публикувани спецификациите на ECMAScript-2015?', '');
@@ -184,10 +188,17 @@ alert( message );
184188

185189
В началото може да е трудно да разберете какво се случва. Но след по-подробно разглеждане можем да видим, че това е просто обикновена последователност от тестове:
186190

191+
<<<<<<< HEAD
187192
1. Първият терминален оператор проверява `age < 3`.
188193
2. Ако е вярно -- връща `'Здравей, бебчо!'`. Иначе продължава израза след '":"', проверявайки `age < 18`.
189194
3. Ако е вярно -- връща `'Здравей!'`. Иначе продължава израза след '":"', проверявайки `age < 100`.
190195
4. Ако е вярно -- връща `'Поздрави!'`. Иначе продължава израза след '":"', и връща `'Каква необичайна възраст!'`.
196+
=======
197+
1. The first question mark checks whether `age < 3`.
198+
2. If true -- it returns `'Hi, baby!'`. Otherwise, it continues to the expression after the colon ":", checking `age < 18`.
199+
3. If that's true -- it returns `'Hello!'`. Otherwise, it continues to the expression after the next colon ":", checking `age < 100`.
200+
4. If that's true -- it returns `'Greetings!'`. Otherwise, it continues to the expression after the last colon ":", returning `'What an unusual age!'`.
201+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
191202
192203
Ето как изглежда ако бихме използвали `if..else`:
193204

1-js/02-first-steps/12-nullish-coalescing-operator/article.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ alert(user ?? "Anonymous"); // Anonymous (user is undefined)
4848
```js run
4949
let user = "John";
5050

51-
alert(user ?? "Anonymous"); // John (user is not null/udefined)
51+
alert(user ?? "Anonymous"); // John (user is not null/undefined)
5252
```
5353
5454
Можем да използваме и последователност от `??` за да изберем първата стойност от списък, който стойности не са `null/undefined`.
@@ -93,9 +93,13 @@ alert(firstName || lastName || nickName || "Anonymous"); // Supercoder
9393
*/!*
9494
```
9595
96+
<<<<<<< HEAD
9697
ИЛИ `||` операторът съществува от началото на JavaScript, така че разработчиците го използваха за такива цели дълго време.
9798
9899
От друга страна, нулевият условен оператор `??` е добавен към JavaScript едва наскоро, и причината за това беше, че хората не бяха съвсем доволни с `||`.
100+
=======
101+
Historically, the OR `||` operator was there first. It's been there since the beginning of JavaScript, so developers were using it for such purposes for a long time.
102+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
99103
100104
Важната разлика е в това:
101105

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ typeof function(){} == "function" // функциите се третират с
107107

108108
Ние използваме браузър като работна среда, така че обикновените функции на потребителския интерфейс ще са:
109109

110+
<<<<<<< HEAD
110111
[`prompt(question, [default])`](mdn:api/Window/prompt)
111112
: Да попитаме за `question`, и да върнем това, което потребителят е въвел или `null` ако са натиснали "Cancel" (Отказ).
112113

@@ -115,6 +116,16 @@ typeof function(){} == "function" // функциите се третират с
115116

116117
[`alert(message)`](mdn:api/Window/alert)
117118
: Изпринтира `message`.
119+
=======
120+
[`prompt(question, [default])`](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt)
121+
: Ask a `question`, and return either what the visitor entered or `null` if they clicked "cancel".
122+
123+
[`confirm(question)`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm)
124+
: Ask a `question` and suggest to choose between Ok and Cancel. The choice is returned as `true/false`.
125+
126+
[`alert(message)`](https://developer.mozilla.org/en-US/docs/Web/API/Window/alert)
127+
: Output a `message`.
128+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
118129
119130
Всички тези функции са *модални*, т.е. спират изпълнението на кода и не позволяват на посетителя да взаимодейства със страницата, докато не отговори.
120131

@@ -152,8 +163,12 @@ JavaScript поддържа следните оператори:
152163
: Побитовите операции работят с 32 битови цели числа в най-ниското побитово ниво: погледнете [документацията](mdn:/JavaScript/Reference/Operators/Bitwise_Operators) когато ви e нужнo.
153164
=======
154165
Bitwise
166+
<<<<<<< HEAD
155167
: Bitwise operators work with 32-bit integers at the lowest, bit-level: see the [docs](mdn:/JavaScript/Guide/Expressions_and_Operators#bitwise_operators) when they are needed.
156168
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
169+
=======
170+
: Bitwise operators work with 32-bit integers at the lowest, bit-level: see the [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise_operators) when they are needed.
171+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
157172
158173
```js run
159174
alert(5 & 13); // 0101 & 1101 = 0101

1-js/04-object-basics/09-object-toprimitive/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,12 @@ In contrast, `Symbol.toPrimitive` is stricter, it *must* return a primitive, oth
322322
=======
323323
If we pass an object as an argument, then there are two stages of calculations:
324324
1. The object is converted to a primitive (using the rules described above).
325+
<<<<<<< HEAD
325326
2. If the necessary for further calculations, the resulting primitive is also converted.
326327
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
328+
=======
329+
2. If necessary for further calculations, the resulting primitive is also converted.
330+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c
327331
328332
Например:
329333

1-js/05-data-types/03-string/article.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ alert( "S\u0307\u0323".normalize() == "\u1e68" ); // true
811811
812812
- There are 3 types of quotes. Backticks allow a string to span multiple lines and embed expressions `${…}`.
813813
- We can use special characters, such as a line break `\n`.
814-
- To get a character, use: `[]`.
814+
- To get a character, use: `[]` or `at` method.
815815
- To get a substring, use: `slice` or `substring`.
816816
- To lowercase/uppercase a string, use: `toLowerCase/toUpperCase`.
817817
- To look for a substring, use: `indexOf`, or `includes/startsWith/endsWith` for simple checks.
@@ -830,4 +830,7 @@ alert( "S\u0307\u0323".normalize() == "\u1e68" ); // true
830830
Strings also have methods for doing search/replace with regular expressions. But that's big topic, so it's explained in a separate tutorial section <info:regular-expressions>.
831831
832832
Also, as of now it's important to know that strings are based on Unicode encoding, and hence there're issues with comparisons. There's more about Unicode in the chapter <info:unicode>.
833+
<<<<<<< HEAD
833834
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
835+
=======
836+
>>>>>>> 285083fc71ee3a7cf55fd8acac9c91ac6f62105c

1-js/05-data-types/04-array/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ let fruits = [
9898

9999
Let's say we want the last element of the array.
100100

101-
Some programming languages allow to use negative indexes for the same purpose, like `fruits[-1]`.
101+
Some programming languages allow the use of negative indexes for the same purpose, like `fruits[-1]`.
102102

103103
Although, in JavaScript it won't work. The result will be `undefined`, because the index in square brackets is treated literally.
104104

1-js/05-data-types/05-array-methods/article.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ alert( arr.includes(1) ); // true
255255

256256
Please note that `indexOf` uses the strict equality `===` for comparison. So, if we look for `false`, it finds exactly `false` and not the zero.
257257

258-
If we want to check if `item` exists in the array, and don't need the exact index, then `arr.includes` is preferred.
258+
If we want to check if `item` exists in the array, and don't need the index, then `arr.includes` is preferred.
259259

260260
The method [arr.lastIndexOf](mdn:js/Array/lastIndexOf) is the same as `indexOf`, but looks for from right to left.
261261

@@ -338,8 +338,6 @@ alert(users.findIndex(user => user.name == 'John')); // 0
338338
alert(users.findLastIndex(user => user.name == 'John')); // 3
339339
```
340340
341-
342-
343341
### filter
344342
345343
The `find` method looks for a single (first) element that makes the function return `true`.

0 commit comments

Comments
 (0)