02. Optional Catch
The shorthand syntax for catch expression will be available in ES2018:
try {
···
} catch {
···
}There are two general reasons for omitting the catch binding:
If you want to completely ignore the error.
You don’t care about the error or you already know what it will be, but you do want to react to it.
let jsonData;
try {
jsonData = JSON.parse(str); // (A)
} catch {
jsonData = DEFAULT_DATA;
}Last updated
Was this helpful?