Skip to content
Merged

sync #28

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
dc9683e
misspell
joaquinelio Jul 13, 2022
a89d952
Removed incorrect info on tail recursion
jbritton6 Jul 13, 2022
18cecd3
Additional info on tail-recursion definition
jbritton6 Jul 13, 2022
0d7f954
Update index.html
iwanderer Jul 14, 2022
374d0b3
add runs buttons
Rnbsov Jul 15, 2022
410279a
Update precedence for ??, It's 3 instead of 4
san1811 Jul 16, 2022
9cba389
Fix typo in pointercancel section
dreamleak Jul 16, 2022
1bbb11c
Update article.md
xmready Jul 18, 2022
52a6df9
feat: type conversion for string with whitespace
leviding Jul 20, 2022
69d180e
Update the operator precedence table
romanstetsyk Jul 21, 2022
2118abb
Update article.md
bhushan Jul 25, 2022
e850873
docs: fix typo (missing verb)
kushanksriraj Jul 27, 2022
f505ecb
Update conditions for choosing between toString and valueOf
chilipenko Jul 28, 2022
abaaae5
Add Number.isNaN and Number.isFinite
chilipenko Aug 1, 2022
5a43f6f
Correcting for correct precedence number
LarsiParsii Aug 2, 2022
187dee3
Fixed a typo
gionathas Aug 5, 2022
b693927
fix: typo
leviding Aug 5, 2022
f54a20a
fix: typo
leviding Aug 7, 2022
03dfa1d
Fix typos in array methods article.md
psychemist Aug 7, 2022
9c0337d
fix: shash -> backslash
leviding Aug 7, 2022
35e2ed2
FIX: "ReferenceError: arr is not defined"
rmarasigan Aug 8, 2022
49af0be
Correct the English and made minor improvements
peterhauke Aug 8, 2022
ebe29f2
Update article.md (fix '??' and '||' operators precedence number)
Aug 9, 2022
7df4cbb
Add Number.isNaN and Number.isFinite to the summary
chilipenko Aug 11, 2022
91ec60d
Commentary in the wrong line
betofc89 Aug 11, 2022
03c5ceb
fix: typo
leviding Aug 13, 2022
4935538
Edit precedence of `??` and `||`
SUPERustam Aug 13, 2022
b923029
Merge pull request #3146 from SUPERustam/patch-1
iliakan Aug 14, 2022
e6b86f9
Merge pull request #3108 from dreamleak/patch-1
iliakan Aug 14, 2022
313b174
Merge pull request #3110 from xmready/patch-1
iliakan Aug 14, 2022
5d57a04
closes #3111
iliakan Aug 14, 2022
caaa05b
Merge pull request #3113 from leviding/patch-2
iliakan Aug 14, 2022
15dacc1
Merge pull request #3117 from romanstetsyk/master
iliakan Aug 14, 2022
e82267e
Merge pull request #3118 from bhushan/patch-1
iliakan Aug 14, 2022
c7da1a0
closes #3119
iliakan Aug 14, 2022
ed1b44e
Merge pull request #3120 from kushanksriraj/patch-1
iliakan Aug 14, 2022
f0f4366
Merge pull request #3121 from chilipenko/patch-1
iliakan Aug 14, 2022
962fa79
closes #3122
iliakan Aug 14, 2022
3bfb6cd
Merge pull request #3125 from chilipenko/patch-2
iliakan Aug 14, 2022
8d4df20
minor fixes
iliakan Aug 14, 2022
422bc3b
Merge pull request #3128 from LarsiParsii/patch-1
iliakan Aug 14, 2022
e76420a
Merge pull request #3130 from gionny96/patch-1
iliakan Aug 14, 2022
f9e0a8b
Merge pull request #3131 from leviding/patch-3
iliakan Aug 14, 2022
bc0b21c
Merge pull request #3133 from leviding/patch-4
iliakan Aug 14, 2022
2dbb4f5
Merge pull request #3134 from 110nard0/patch-1
iliakan Aug 14, 2022
12cc61f
Merge pull request #3135 from leviding/patch-5
iliakan Aug 14, 2022
d98cf52
Merge pull request #3136 from rmarasigan/patch-1
iliakan Aug 14, 2022
eee5b94
Merge pull request #3139 from peterhauke/patch-3
iliakan Aug 14, 2022
1eb3a57
Merge pull request #3140 from vcodepro/master
iliakan Aug 14, 2022
2f9a190
Merge pull request #3142 from betofc89/patch-1
iliakan Aug 14, 2022
6a18f47
Merge pull request #3145 from leviding/patch-6
iliakan Aug 14, 2022
4f3b02f
Merge pull request #3107 from san1811/patch-1
iliakan Aug 14, 2022
fb76d3b
Merge pull request #3105 from Rnbsov/patch-73
iliakan Aug 14, 2022
01f6378
Merge pull request #3103 from iwanderer/patch-1
iliakan Aug 14, 2022
4a98342
Merge pull request #3101 from jbritton6/patch-1
iliakan Aug 14, 2022
cbd7d78
Merge pull request #3100 from joaquinelio/patch-11
iliakan Aug 14, 2022
72aa4f0
minor fixes
iliakan Aug 14, 2022
d738e31
Grammar correction
zaks276 Aug 14, 2022
1edb0a3
Merge pull request #3147 from zaks276/patch-1
iliakan Aug 16, 2022
c1a734f
merging all conflicts
iliakan Aug 22, 2022
fd40fad
Update article.md
otmon76 Aug 22, 2022
102d106
Update article.md
otmon76 Aug 22, 2022
b940036
Update article.md
otmon76 Aug 22, 2022
9f0673a
Update article.md
otmon76 Aug 22, 2022
d8de43c
Update article.md
otmon76 Aug 22, 2022
6dc5032
Merge pull request #116 from javascript-tutorial/sync-1edb0a38
otmon76 Aug 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Výše uvedené pojmy je dobré si pamatovat, protože se používají ve vývoj
Enginy jsou složité, ale jejich základy jsou jednoduché.

1. Engine (v případě prohlížeče zahrnutý do něj) načte („rozebere“, „parsuje“) skript.
2. Pak přeloží („zkompiluje“) skript do strojového jazyka.
2. Pak přeloží („zkompiluje“) skript do strojového kódu.
3. A pak se strojový kód hezky rychle spustí.

Při každém kroku procesu engine aplikuje optimalizace. Dokonce sleduje, jak zkompilovaný skript běží, analyzuje data, která jím protékají, a podle těchto znalostí dále optimalizuje strojový kód.
Expand All @@ -59,7 +59,7 @@ Například JavaScript v prohlížeči může:

## Co NEMŮŽE JavaScript v prohlížeči dělat?

Schopnosti JavaScriptu v prohlížeči jsou omezeny v zájmu bezpečnosti uživatele. Cílem je zabránit zlé webové stránce v přístupu k soukromým informacím nebo v poškození uživatelových dat.
Schopnosti JavaScriptu v prohlížeči jsou omezeny, aby byla chráněna bezpečnost uživatele. Cílem je zabránit zlé webové stránce v přístupu k soukromým informacím nebo v poškození uživatelových dat.

Příklady takových omezení:

Expand All @@ -70,9 +70,9 @@ Příklady takových omezení:
Existují způsoby, jak komunikovat s kamerou, mikrofonem nebo jinými zařízeními, ale ty vyžadují výslovné svolení uživatele. Stránka s povoleným JavaScriptem tedy nemůže bez vědomí uživatele zapnout webovou kameru, nasnímat okolí a nahrávku poslat do [NSA](https://cs.wikipedia.org/wiki/Národní_bezpečnostní_agentura).
- Různé záložky a okna o sobě navzájem obvykle nevědí. Někdy ano, například tehdy, když jedno okno používá JavaScript k otevření druhého. Ale ani v tomto případě JavaScript z jedné stránky nemůže přistupovat k jiné, pokud pocházejí z různých webových sídel (z jiné domény, protokolu nebo portu).

Tento postup se nazývá „politika stejného původu“. Je možné ji obejít tak, že *obě stránky* souhlasí s výměnou dat a obsahují speciální JavaScriptový kód, který to umožňuje. V tomto tutoriálu to budeme probírat.
Tento postup se nazývá „politika stejného původu“. Je možné ji obejít tak, že *obě stránky* musí souhlasit s výměnou dat a musí obsahovat speciální JavaScriptový kód, který to umožňuje. V tomto tutoriálu to budeme probírat.

Toto omezení je zde opět pro bezpečnost uživatele. Stránka z `http://anysite.com`, kterou uživatel otevřel, nesmí mít možnost přistupovat k jiné záložce prohlížeče s URL `http://gmail.com` a krást odtamtud informace.
Toto omezení je zde opět pro bezpečnost uživatele. Stránka z `http://anysite.com`, kterou uživatel otevřel, nesmí mít možnost přistupovat k jiné záložce prohlížeče s URL například `http://gmail.com` a krást odtamtud informace.
- JavaScript může jednoduše komunikovat po síti se serverem, z něhož přišla aktuální stránka, ale jeho schopnost získávat data z jiných sídel/domén je značně omezená. Přestože je to možné, vyžaduje to výslovný souhlas (uvedený v HTTP hlavičce) vzdálené strany. I to je bezpečnostní omezení.

![](limitations.svg)
Expand All @@ -92,7 +92,7 @@ JavaScript je jediná prohlížečová technologie, která má všechny tyto tř

To vše činí JavaScript unikátním. To vše je důvodem, proč je dnes nejrozšířenějším nástrojem pro vytváření prohlížečových rozhraní.

Při tom všem však JavaScript umožňuje vytvářet i servery, mobilní aplikace a podobně.
Při tom všem však lze JavaScript použít i k vytváření serverů, mobilních aplikací a podobně.

## Jazyky „nad“ JavaScriptem

Expand All @@ -113,7 +113,7 @@ Příklady takových jazyků:
- [Brython](https://brython.info/) je transpiler Pythonu do JavaScriptu, který umožňuje psát aplikace v čistém Pythonu bez JavaScriptu.
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) je moderní, stručný a bezpečný programovací jazyk, jehož cílem může být prohlížeč nebo Node.

Jsou i další. Samozřejmě i když používáme některý z transpilovaných jazyků, měli bychom znát i JavaScript, abychom skutečně porozuměli tomu, co se děje.
Jsou i další. Samozřejmě i když používáme některý z těchto transpilovaných jazyků, měli bychom znát i JavaScript, abychom skutečně porozuměli tomu, co se děje.

## Shrnutí

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/07-type-conversions/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Pravidla pro konverzi na číslo:
|`undefined`|`NaN`|
|`null`|`0`|
|<code>true</code>&nbsp;a&nbsp;<code>false</code> | `1` a `0` |
| `řetězec` | Odstraní se bílé znaky (mezery, tabulátory, konce řádku) ze začátku a konce. Je-li výsledný řetězec prázdný, výsledkem je `0`. Jinak se číslo „přečte“ z řetězce. Při chybě je vydáno `NaN`. |
| `řetězec` | Odstraní se bílé znaky (mezery, tabulátory `\t`, konce řádku `\n` atd.) ze začátku a konce. Je-li výsledný řetězec prázdný, výsledkem je `0`. Jinak se číslo „přečte“ z řetězce. Při chybě je vydáno `NaN`. |

Příklady:

Expand Down Expand Up @@ -130,7 +130,7 @@ Konverze se řídí těmito pravidly:
|`undefined`|`NaN`|
|`null`|`0`|
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
| `řetězec` | Načte se „doslovně“, bílé znaky na obou stranách se ignorují. Z prázdného řetězce se stane `0`. Při chybě je vydáno `NaN`. |
| `řetězec` | Načte se „doslovně“, bílé znaky (mezery, tabulátory `\t`, konce řádku `\n` atd.) na obou stranách se ignorují. Z prázdného řetězce se stane `0`. Při chybě je vydáno `NaN`. |

**`Konverze na boolean`** -- Nastává při logických operacích. Můžeme ji provést pomocí `Boolean(hodnota)`.

Expand Down
20 changes: 10 additions & 10 deletions 1-js/02-first-steps/08-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ Následuje výtažek z [tabulky priorit](https://developer.mozilla.org/en-US/doc
| Priorita | Název | Znak |
|----------|-------|------|
| ... | ... | ... |
| 15 | unární plus | `+` |
| 15 | unární negace | `-` |
| 14 | umocňování | `**` |
| 13 | násobení | `*` |
| 13 | dělení | `/` |
| 12 | sčítání | `+` |
| 12 | odčítání | `-` |
| 14 | unární plus | `+` |
| 14 | unární negace | `-` |
| 13 | umocňování | `**` |
| 12 | násobení | `*` |
| 12 | dělení | `/` |
| 11 | sčítání | `+` |
| 11 | odčítání | `-` |
| ... | ... | ... |
| 2 | přiřazení | `=` |
| ... | ... | ... |

Jak vidíme, „unární plus“ má prioritu `15`, která je vyšší než priorita `12` „sčítání“ (binární plus). To je důvod, proč se ve výrazu `"+jablka + +pomeranče"` unární plusy vyhodnotí před sčítáním.
Jak vidíme, „unární plus“ má prioritu `14`, která je vyšší než priorita `11` „sčítání“ (binární plus). To je důvod, proč se ve výrazu `"+jablka + +pomeranče"` unární plusy vyhodnotí před sčítáním.

## Přiřazení

Expand Down Expand Up @@ -304,9 +304,9 @@ Tyto operátory mají stejnou prioritu jako běžné přiřazení, takže se pro
```js run
let n = 2;

n *= 3 + 5;
n *= 3 + 5; // napřed se provede část vpravo, totéž jako n *= 8

alert( n ); // 16 (napřed se provede část vpravo, totéž jako n *= 8)
alert( n ); // 16
```

## Inkrementace a dekrementace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ V praxi je nulová výška často platnou hodnotou, takže by neměla být nahra

## Priorita

Priorita operátoru `??` je stejná jako `||`. Oba operátory mají v [tabulce MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) prioritu `4`.
Priorita operátoru `??` je stejná jako `||`. Oba operátory mají v [tabulce MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) prioritu `3`.

To znamená, že operátor koalescence `??` se stejně jako `||` vyhodnocuje před `=` a `?`, ale až po většině ostatních operací, například `+`, `*`.

Expand Down
8 changes: 7 additions & 1 deletion 1-js/02-first-steps/15-function-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Napřed je uvedeno klíčové slovo `function`, pak *název funkce*, potom máme

```js
function název(parametr1, parametr2, ... parametrN) {
...tělo...
// tělo
}
```

Expand Down Expand Up @@ -209,6 +209,12 @@ zobrazZprávu("Anna"); // Anna: text není zadán

Jestliže argument k parametru `text` nebude předán, bude mít hodnotu `"text není zadán"`.

Výchozí hodnota bude nastavena i tehdy, když parametr existuje, ale je striktně roven `undefined`, například:

```js
showMessage("Anna", undefined); // Anna: text není zadán
```

Zde `"text není zadán"` je řetězec, ale může to být složitější výraz, který se vyhodnotí a přiřadí jen tehdy, jestliže argument chybí. Je tedy možné i toto:

```js run
Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/05-testing-mocha/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ So, the development is *iterative*. We write the spec, implement it, make sure t

Let's see this development flow in our practical case.

The first step is already complete: we have an initial spec for `pow`. Now, before making the implementation, let's use few JavaScript libraries to run the tests, just to see that they are working (they will all fail).
The first step is already complete: we have an initial spec for `pow`. Now, before making the implementation, let's use a few JavaScript libraries to run the tests, just to see that they are working (they will all fail).

## The spec in action

Expand Down
4 changes: 2 additions & 2 deletions 1-js/04-object-basics/09-object-toprimitive/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ As we can see from the code, `user` becomes a self-descriptive string or a money

If there's no `Symbol.toPrimitive` then JavaScript tries to find methods `toString` and `valueOf`:

- For the `"string"` hint: call `toString` method, and if it doesn't exist, then `valueOf` (so `toString` has the priority for string conversions).
- For other hints: `valueOf`, and if it doesn't exist, then `toString` (so `valueOf` has the priority for maths).
- For the `"string"` hint: call `toString` method, and if it doesn't exist or if it returns an object instead of a primitive value, then call `valueOf` (so `toString` has the priority for string conversions).
- For other hints: call `valueOf`, and if it doesn't exist or if it returns an object instead of a primitive value, then call `toString` (so `valueOf` has the priority for maths).

Methods `toString` and `valueOf` come from ancient times. They are not symbols (symbols did not exist that long ago), but rather "regular" string-named methods. They provide an alternative "old-style" way to implement the conversion.

Expand Down
37 changes: 34 additions & 3 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,44 @@ alert( isFinite(num) );

Please note that an empty or a space-only string is treated as `0` in all numeric functions including `isFinite`.

```smart header="Compare with `Object.is`"
````smart header="`Number.isNaN` and `Number.isFinite`"
[Number.isNaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) and [Number.isFinite](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite) methods are the more "strict" versions of `isNaN` and `isFinite` functions. They do not autoconvert their argument into a number, but check if it belongs to the `number` type instead.

- `Number.isNaN(value)` returns `true` if the argument belongs to the `number` type and it is `NaN`. In any other case it returns `false`.

```js run
alert( Number.isNaN(NaN) ); // true
alert( Number.isNaN("str" / 2) ); // true

// Note the difference:
alert( Number.isNaN("str") ); // false, because "str" belongs to the string type, not the number type
alert( isNaN("str") ); // true, because isNaN converts string "str" into a number and gets NaN as a result of this conversion
```

- `Number.isFinite(value)` returns `true` if the argument belongs to the `number` type and it is not `NaN/Infinity/-Infinity`. In any other case it returns `false`.

```js run
alert( Number.isFinite(123) ); // true
alert( Number.isFinite(Infinity) ); //false
alert( Number.isFinite(2 / 0) ); // false

// Note the difference:
alert( Number.isFinite("123") ); // false, because "123" belongs to the string type, not the number type
alert( isFinite("123") ); // true, because isFinite converts string "123" into a number 123
```

In a way, `Number.isNaN` and `Number.isFinite` are simpler and more straightforward than `isNaN` and `isFinite` functions. In practice though, `isNaN` and `isFinite` are mostly used, as they're shorter to write.
````

```smart header="Comparison with `Object.is`"
There is a special built-in method `Object.is` that compares values like `===`, but is more reliable for two edge cases:

1. It works with `NaN`: `Object.is(NaN, NaN) === true`, that's a good thing.
2. Values `0` and `-0` are different: `Object.is(0, -0) === false`, technically that's true, because internally the number has a sign bit that may be different even if all other bits are zeroes.

In all other cases, `Object.is(a, b)` is the same as `a === b`.

This way of comparison is often used in JavaScript specification. When an internal algorithm needs to compare two values for being exactly the same, it uses `Object.is` (internally called [SameValue](https://tc39.github.io/ecma262/#sec-samevalue)).
We mention `Object.is` here, because it's often used in JavaScript specification. When an internal algorithm needs to compare two values for being exactly the same, it uses `Object.is` (internally called [SameValue](https://tc39.github.io/ecma262/#sec-samevalue)).
```


Expand Down Expand Up @@ -435,7 +464,9 @@ For different numeral systems:
For regular number tests:

- `isNaN(value)` converts its argument to a number and then tests it for being `NaN`
- `isFinite(value)` converts its argument to a number and returns `true` if it's a regular number, not `NaN/Infinity/-Infinity`
- `Number.isNaN(value)` checks whether its argument belongs to the `number` type, and if so, tests it for being `NaN`
- `isFinite(value)` converts its argument to a number and then tests it for not being `NaN/Infinity/-Infinity`
- `Number.isFinite(value)` checks whether its argument belongs to the `number` type, and if so, tests it for not being `NaN/Infinity/-Infinity`

For converting values like `12pt` and `100px` to a number:

Expand Down
2 changes: 2 additions & 0 deletions 1-js/05-data-types/03-string/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ There are 3 methods in JavaScript to get a substring: `substring`, `substr` and
alert( str.substr(-4, 2) ); // 'gi', from the 4th position get 2 characters
```

This method resides in the [Annex B](https://tc39.es/ecma262/#sec-string.prototype.substr) of the language specification. It means that only browser-hosted Javascript engines should support it, and it's not recommended to use it. In practice, it's supported everywhere.

Let's recap these methods to avoid any confusion:

| method | selects... | negatives |
Expand Down
4 changes: 2 additions & 2 deletions 1-js/05-data-types/05-array-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ The method [arr.lastIndexOf](mdn:js/Array/lastIndexOf) is the same as `indexOf`,
```js run
let fruits = ['Apple', 'Orange', 'Apple']

alert( arr.indexOf('Apple') ); // 0 (first Apple)
alert( arr.lastIndexOf('Apple') ); // 2 (last Apple)
alert( fruits.indexOf('Apple') ); // 0 (first Apple)
alert( fruits.lastIndexOf('Apple') ); // 2 (last Apple)
```

````smart header="The `includes` method handles `NaN` correctly"
Expand Down
4 changes: 2 additions & 2 deletions 1-js/05-data-types/06-iterable/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ alert(arr.pop()); // World (method works)

The same happens for an iterable:

```js
```js run
// assuming that range is taken from the example above
let arr = Array.from(range);
alert(arr); // 1,2,3,4,5 (array toString conversion works)
Expand All @@ -233,7 +233,7 @@ The optional second argument `mapFn` can be a function that will be applied to e

For instance:

```js
```js run
// assuming that range is taken from the example above

// square each number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ P.S. Naturally, the formula is the fastest solution. It uses only 3 operations f

The loop variant is the second in terms of speed. In both the recursive and the loop variant we sum the same numbers. But the recursion involves nested calls and execution stack management. That also takes resources, so it's slower.

P.P.S. Some engines support the "tail call" optimization: if a recursive call is the very last one in the function (like in `sumTo` above), then the outer function will not need to resume the execution, so the engine doesn't need to remember its execution context. That removes the burden on memory, so counting `sumTo(100000)` becomes possible. But if the JavaScript engine does not support tail call optimization (most of them don't), there will be an error: maximum stack size exceeded, because there's usually a limitation on the total stack size.
P.P.S. Some engines support the "tail call" optimization: if a recursive call is the very last one in the function, with no other calculations performed, then the outer function will not need to resume the execution, so the engine doesn't need to remember its execution context. That removes the burden on memory. But if the JavaScript engine does not support tail call optimization (most of them don't), there will be an error: maximum stack size exceeded, because there's usually a limitation on the total stack size.
4 changes: 2 additions & 2 deletions 1-js/11-async/02-promise-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ So to summarize: the executor runs automatically and attempts to perform a job.
The `promise` object returned by the `new Promise` constructor has these internal properties:

- `state` — initially `"pending"`, then changes to either `"fulfilled"` when `resolve` is called or `"rejected"` when `reject` is called.
- `result` — initially `undefined`, then changes to `value` when `resolve(value)` called or `error` when `reject(error)` is called.
- `result` — initially `undefined`, then changes to `value` when `resolve(value)` is called or `error` when `reject(error)` is called.

So the executor eventually moves `promise` to one of these states:

Expand Down Expand Up @@ -281,7 +281,7 @@ To summarize:
- If a `finally` handler returns something, it's ignored.
- When `finally` throws an error, then the execution goes to the nearest error handler.

These features are helpful and make things work just the right way if we `finally` how it's supposed to be used: for generic cleanup procedures.
These features are helpful and make things work just the right way if we use `finally` how it's supposed to be used: for generic cleanup procedures.

````smart header="We can attach handlers to settled promises"
If a promise is pending, `.then/catch/finally` handlers wait for its outcome.
Expand Down
2 changes: 1 addition & 1 deletion 2-ui/1-document/05-basic-dom-node-properties/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The classes are:

- [Document](https://dom.spec.whatwg.org/#interface-document), for historical reasons often inherited by `HTMLDocument` (though the latest spec doesn't dictate it) -- is a document as a whole.

The `document` global object belongs exactly to this class. It servers as an entry point to the DOM.
The `document` global object belongs exactly to this class. It serves as an entry point to the DOM.

- [CharacterData](https://dom.spec.whatwg.org/#interface-characterdata) -- an "abstract" class, inherited by:
- [Text](https://dom.spec.whatwg.org/#interface-text) -- the class corresponding to a text inside elements, e.g. `Hello` in `<p>Hello</p>`.
Expand Down
Loading