refactor classes, add private, minor fixes
This commit is contained in:
parent
a0c07342ad
commit
1373f6158c
270 changed files with 1513 additions and 890 deletions
|
@ -0,0 +1,13 @@
|
|||
The answer is: **no, it won't**:
|
||||
|
||||
```js run
|
||||
new Promise(function(resolve, reject) {
|
||||
setTimeout(() => {
|
||||
throw new Error("Whoops!");
|
||||
}, 1000);
|
||||
}).catch(alert);
|
||||
```
|
||||
|
||||
As said in the chapter, there's an "implicit `try..catch`" around the function code. So all synchronous errors are handled.
|
||||
|
||||
But here the error is generated not while the executor is running, but later. So the promise can't handle it.
|
|
@ -0,0 +1,11 @@
|
|||
# Error in setTimeout
|
||||
|
||||
What do you think? Will the `.catch` trigger? Explain your answer.
|
||||
|
||||
```js
|
||||
new Promise(function(resolve, reject) {
|
||||
setTimeout(() => {
|
||||
throw new Error("Whoops!");
|
||||
}, 1000);
|
||||
}).catch(alert);
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue