This commit is contained in:
Ilya Kantor 2017-04-18 00:26:35 +02:00
parent 57dc058c49
commit f57be1bbb3
5 changed files with 221 additions and 46 deletions

View 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.

View 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);
```