Skip to content

Commit 4c3be1c

Browse files
committed
try and catch are synchronous
1 parent ffecd16 commit 4c3be1c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

errorhandling.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ try {
99
}
1010

1111

12+
//try...catch works synchronously
13+
setTimeout(function () {
14+
try {
15+
noSuchVariable; // try...catch handles the error!
16+
} catch {
17+
console.log("error is caught here!");
18+
}
19+
}, 1000);

0 commit comments

Comments
 (0)