Skip to content

Commit cebefb4

Browse files
authored
Merge pull request #186 from javascript-tutorial/merge-upstream
Merge upstream
2 parents e597b6c + 237a30d commit cebefb4

File tree

37 files changed

+1939
-169
lines changed

37 files changed

+1939
-169
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ let имя = '...';
205205
let 我 = '...';
206206
```
207207
208-
Նման անունները վավեր են, սակայն ամենուր ընդունված է օգտագործել անգլերենը: Նույնիսկ եթե փոքր սկրիպտ եք գրում, այն հնարավոր է կարդան նաև այլազգի ծրագրավորողները:
208+
Այստեղ սխալ չկա։ Նման անունները վավեր են, սակայն ամենուր ընդունված է օգտագործել անգլերենը: Նույնիսկ եթե փոքր սկրիպտ եք գրում, այն հնարավոր է կարդան նաև այլազգի ծրագրավորողները:
209209
````
210210

211211
````warn header="Վերապահված անուններ (reserved names)"
@@ -264,7 +264,7 @@ myBirthday = '01.01.2001'; // error, can't reassign the constant!
264264
265265
### Մեծատառ հաստատուններ
266266
267-
Ընդունված է օգտագործել հաստատունները դժվար հիշվող արժեքների համար, որոնք հայտնի են նախօրոք:
267+
Ընդունված է հաստատունները օգտագործել դժվար հիշվող արժեքների համար, որոնք հայտնի են նախօրոք:
268268
269269
Նման հաստատունները գրվում են մեծատառ և ընդգծիկներով (underscores):
270270
@@ -289,15 +289,15 @@ alert(color); // #FF7F00
289289
290290
Եկեք հասկանանք երբ է պետք հաստատունները գրել մեծատառերով, իսկ երբ ոչ:
291291
292-
«Հաստատունն» ուղղակի փոփոխական է, որի արժեքը չի փոխվում: Այունամենայնիվ կան հաստատուններ, որոնց արժեքը հայտնի է մինչև սկրիպը գործարկելը (ինչպես, օրինակ, վերոնշյալ գույները) և կան հաստատուններ, որոնց արժեքը հայտնի է դառնում միայն սկրիպտի աշխատանքի ընթացքում և այն չի փոխվում սկզբնական վերագրումից հետո:
292+
«Հաստատունն» ուղղակի փոփոխական է, որի արժեքը չի փոխվում: Կան հաստատուններ, որոնց արժեքը հայտնի է մինչև սկրիպտը գործարկելը (ինչպես, օրինակ, վերոնշյալ գույները) և կան հաստատուններ, որոնց արժեքը հայտնի է դառնում միայն սկրիպտի աշխատանքի ընթացքում և այն չի փոխվում սկզբնական վերագրումից հետո:
293293
294294
Օրինակ՝
295295
296296
```js
297297
const pageLoadTime = /* time taken by a webpage to load */;
298298
```
299299
300-
`pageLoadTime`-ի արժեքը հայտնի չէ, քանի դեռ էջն ամբողջությամբ չի բեռնվել, սակայն այն հաստատուն է, քանի որ արժեքը չի փոխվում:
300+
`pageLoadTime`-ի արժեքը հայտնի չէ, քանի դեռ էջն ամբողջությամբ չի բեռնվել, այդ իսկ պատճառով այն մեծատառ չէ։ Սակայն այն հաստատուն է, քանի որ վերագրելուց հետո արժեքը չի փոխվում:
301301
302302
Այլ կերպ ասած՝ մեծատառերով գրված հաստատունները օգտագործվում են միայն որպես «կոշտ կոդավորված» արժեքների փոխանուններ:
303303

Diff for: 1-js/03-code-quality/06-polyfills/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Teams behind JavaScript engines have their own ideas about what to implement fir
77

88
So it's quite common for an engine to implement only part of the standard.
99

10-
A good page to see the current state of support for language features is <https://kangax.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
10+
A good page to see the current state of support for language features is <https://compat-table.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
1111

1212
As programmers, we'd like to use most recent features. The more good stuff - the better!
1313

@@ -85,7 +85,7 @@ Just don't forget to use a transpiler (if using modern syntax or operators) and
8585
For example, later when you're familiar with JavaScript, you can setup a code build system based on [webpack](https://webpack.js.org/) with the [babel-loader](https://github.com/babel/babel-loader) plugin.
8686
8787
Good resources that show the current state of support for various features:
88-
- <https://kangax.github.io/compat-table/es6/> - for pure JavaScript.
88+
- <https://compat-table.github.io/compat-table/es6/> - for pure JavaScript.
8989
- <https://caniuse.com/> - for browser-related functions.
9090
9191
P.S. Google Chrome is usually the most up-to-date with language features, try it if a tutorial demo fails. Most tutorial demos work with any modern browser though.

Diff for: 1-js/05-data-types/03-string/3-truncate/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The result of the function should be the truncated (if needed) string.
1111
For instance:
1212

1313
```js
14-
truncate("What I'd like to tell on this topic is:", 20) = "What I'd like to te…"
14+
truncate("What I'd like to tell on this topic is:", 20) == "What I'd like to te…"
1515

16-
truncate("Hi everyone!", 20) = "Hi everyone!"
16+
truncate("Hi everyone!", 20) == "Hi everyone!"
1717
```

Diff for: 1-js/05-data-types/10-destructuring-assignment/article.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ The two most used data structures in JavaScript are `Object` and `Array`.
55
- Objects allow us to create a single entity that stores data items by key.
66
- Arrays allow us to gather data items into an ordered list.
77

8-
Although, when we pass those to a function, it may need not be an object/array as a whole. It may need individual pieces.
8+
However, when we pass these to a function, we may not need all of it. The function might only require certain elements or properties.
99

1010
*Destructuring assignment* is a special syntax that allows us to "unpack" arrays or objects into a bunch of variables, as sometimes that's more convenient.
1111

12-
Destructuring also works great with complex functions that have a lot of parameters, default values, and so on. Soon we'll see that.
12+
Destructuring also works well with complex functions that have a lot of parameters, default values, and so on. Soon we'll see that.
1313

1414
## Array destructuring
1515

1616
Here's an example of how an array is destructured into variables:
1717

1818
```js
19-
// we have an array with the name and surname
19+
// we have an array with a name and surname
2020
let arr = ["John", "Smith"]
2121

2222
*!*
@@ -40,10 +40,10 @@ alert(firstName); // John
4040
alert(surname); // Smith
4141
```
4242

43-
As you can see, the syntax is simple. There are several peculiar details though. Let's see more examples, to better understand it.
43+
As you can see, the syntax is simple. There are several peculiar details though. Let's see more examples to understand it better.
4444

4545
````smart header="\"Destructuring\" does not mean \"destructive\"."
46-
It's called "destructuring assignment," because it "destructurizes" by copying items into variables. But the array itself is not modified.
46+
It's called "destructuring assignment," because it "destructurizes" by copying items into variables. However, the array itself is not modified.
4747
4848
It's just a shorter way to write:
4949
```js
@@ -65,7 +65,7 @@ let [firstName, , title] = ["Julius", "Caesar", "Consul", "of the Roman Republic
6565
alert( title ); // Consul
6666
```
6767
68-
In the code above, the second element of the array is skipped, the third one is assigned to `title`, and the rest of the array items is also skipped (as there are no variables for them).
68+
In the code above, the second element of the array is skipped, the third one is assigned to `title`, and the rest of the array items are also skipped (as there are no variables for them).
6969
````
7070

7171
````smart header="Works with any iterable on the right-side"
@@ -95,17 +95,17 @@ alert(user.surname); // Smith
9595
````
9696

9797
````smart header="Looping with .entries()"
98-
In the previous chapter we saw the [Object.entries(obj)](mdn:js/Object/entries) method.
98+
In the previous chapter, we saw the [Object.entries(obj)](mdn:js/Object/entries) method.
9999
100-
We can use it with destructuring to loop over keys-and-values of an object:
100+
We can use it with destructuring to loop over the keys-and-values of an object:
101101
102102
```js run
103103
let user = {
104104
name: "John",
105105
age: 30
106106
};
107107
108-
// loop over keys-and-values
108+
// loop over the keys-and-values
109109
*!*
110110
for (let [key, value] of Object.entries(user)) {
111111
*/!*
@@ -169,7 +169,7 @@ If we'd like also to gather all that follows -- we can add one more parameter th
169169
let [name1, name2, *!*...rest*/!*] = ["Julius", "Caesar", *!*"Consul", "of the Roman Republic"*/!*];
170170
171171
*!*
172-
// rest is array of items, starting from the 3rd one
172+
// rest is an array of items, starting from the 3rd one
173173
alert(rest[0]); // Consul
174174
alert(rest[1]); // of the Roman Republic
175175
alert(rest.length); // 2
@@ -187,7 +187,7 @@ let [name1, name2, *!*...titles*/!*] = ["Julius", "Caesar", "Consul", "of the Ro
187187

188188
### Default values
189189

190-
If the array is shorter than the list of variables at the left, there'll be no errors. Absent values are considered undefined:
190+
If the array is shorter than the list of variables on the left, there will be no errors. Absent values are considered undefined:
191191

192192
```js run
193193
*!*
@@ -418,7 +418,7 @@ alert( title ); // Menu
418418
419419
## Nested destructuring
420420
421-
If an object or an array contain other nested objects and arrays, we can use more complex left-side patterns to extract deeper portions.
421+
If an object or an array contains other nested objects and arrays, we can use more complex left-side patterns to extract deeper portions.
422422
423423
In the code below `options` has another object in the property `size` and an array in the property `items`. The pattern on the left side of the assignment has the same structure to extract values from them:
424424
@@ -461,7 +461,7 @@ Note that there are no variables for `size` and `items`, as we take their conten
461461
462462
There are times when a function has many parameters, most of which are optional. That's especially true for user interfaces. Imagine a function that creates a menu. It may have a width, a height, a title, items list and so on.
463463
464-
Here's a bad way to write such function:
464+
Here's a bad way to write such a function:
465465
466466
```js
467467
function showMenu(title = "Untitled", width = 200, height = 100, items = []) {

Diff for: 1-js/05-data-types/12-json/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ To decode a JSON-string, we need another method named [JSON.parse](mdn:js/JSON/p
405405

406406
The syntax:
407407
```js
408-
let value = JSON.parse(str, [reviver]);
408+
let value = JSON.parse(str[, reviver]);
409409
```
410410

411411
str

Diff for: 1-js/08-prototypes/04-prototype-methods/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The only usage of `__proto__`, that's not frowned upon, is as a property when cr
1414

1515
Although, there's a special method for this too:
1616

17-
- [Object.create(proto, [descriptors])](mdn:js/Object/create) -- creates an empty object with given `proto` as `[[Prototype]]` and optional property descriptors.
17+
- [Object.create(proto[, descriptors])](mdn:js/Object/create) -- creates an empty object with given `proto` as `[[Prototype]]` and optional property descriptors.
1818

1919
For instance:
2020

@@ -201,7 +201,7 @@ alert(Object.keys(chineseDictionary)); // hello,bye
201201
- To create an object with the given prototype, use:
202202

203203
- literal syntax: `{ __proto__: ... }`, allows to specify multiple properties
204-
- or [Object.create(proto, [descriptors])](mdn:js/Object/create), allows to specify property descriptors.
204+
- or [Object.create(proto[, descriptors])](mdn:js/Object/create), allows to specify property descriptors.
205205

206206
The `Object.create` provides an easy way to shallow-copy an object with all descriptors:
207207

Diff for: 1-js/13-modules/02-import-export/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ Well, there are few reasons.
9797
2. Explicit list of imports gives better overview of the code structure: what is used and where. It makes code support and refactoring easier.
9898

9999
```smart header="Don't be afraid to import too much"
100-
Modern build tools, such as [webpack](https://webpack.js.org/) and others, bundle modules together and optimize them to speedup loading. They also removed unused imports.
100+
Modern build tools, such as [webpack](https://webpack.js.org/) and others, bundle modules together and optimize them to speedup loading. They also remove unused imports.
101101
102-
For instance, if you `import * as library` from a huge code library, and then use only few methods, then unused ones [will not be included](https://github.com/webpack/webpack/tree/main/examples/harmony-unused#examplejs) into the optimzed bundle.
102+
For instance, if you `import * as library` from a huge code library, and then use only few methods, then unused ones [will not be included](https://github.com/webpack/webpack/tree/main/examples/harmony-unused#examplejs) into the optimized bundle.
103103
```
104104

105105
## Import "as"

0 commit comments

Comments
 (0)