The catch
clause of try
statements used to require a binding:
try {
doSomethingThatMightThrow();
} catch (exception) {
// ^^^^^^^^^
// We must name the binding, even if we don’t use it!
handleException();
}
In ES2019, catch
can now be used without a binding. This is useful if you don’t have a need for the exception
object in the code that handles the exception.
try {
doSomethingThatMightThrow();
} catch { // → No binding!
handleException();
}