work
This commit is contained in:
parent
57dc058c49
commit
f57be1bbb3
5 changed files with 221 additions and 46 deletions
15
8-async/03-promise-chaining/01-then-vs-catch/solution.md
Normal file
15
8-async/03-promise-chaining/01-then-vs-catch/solution.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
The short answer is: **no, they are not**:
|
||||
|
||||
The difference is that if an error happens in `f1`, then it is handled by `.catch` here:
|
||||
|
||||
```js run
|
||||
promise.then(f1).catch(f2);
|
||||
```
|
||||
|
||||
...But not here:
|
||||
|
||||
```js run
|
||||
promise.then(f1, f2);
|
||||
```
|
||||
|
||||
That's because an error/result is passed down the chain, and in the second code piece there's no chain below.
|
12
8-async/03-promise-chaining/01-then-vs-catch/task.md
Normal file
12
8-async/03-promise-chaining/01-then-vs-catch/task.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Promise then vs catch
|
||||
|
||||
Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions?
|
||||
|
||||
```js
|
||||
promise.then(f1, f2);
|
||||
```
|
||||
|
||||
Versus;
|
||||
```js
|
||||
promise.then(f1).catch(f2);
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue