Optional catch binding
Omit the the binding parameter of a catch clause when you don't need information about the exception in a try ... catch statement.
Overview
Omit the the binding parameter of a catch clause when you don't need information about the exception in a try ... catch statement.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
javascript.statements.try_catch.optional_catch_binding | 66 | 79 | 58 | 11.1 | 66 | 11.3 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
JAVASCRIPT
// Traditional
try { JSON.parse(input); } catch (e) { return false; }
// Optional
try { JSON.parse(input); } catch { return false; } Live demo
JSONparse. Errornoneview
Errorobject to, parsefailure time. defaultprocessing concise to describe..
PreviewFullscreen
typeconvert. try row
Convert to failure also errorcontents to that case, catch shinpl to write..
PreviewFullscreen
any. settingsloading
settings. loading in error that emitlive also, to noneviewcontinue rowexample..
PreviewFullscreen
Use cases
Using Optional catch binding
Omit the the binding parameter of a catch clause when you don't need information about the exception in a try ... catch statement.
Cautions
- No specific concerns. Stable across all major browsers.
Accessibility
- When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.
Related links
Powered by web-features