Saltar al contenido principal

Binding opcional en `catch`

· Lectura de un minuto
Mathias Bynens ([@mathias](https://twitter.com/mathias))

La cláusula catch de las sentencias try solía requerir un binding:

try {
doSomethingThatMightThrow();
} catch (exception) {
// ^^^^^^^^^
// ¡Debemos nombrar el binding, incluso si no lo usamos!
handleException();
}

En ES2019, ahora se puede usar catch sin un binding. Esto es útil si no necesitas el objeto exception en el código que maneja la excepción.

try {
doSomethingThatMightThrow();
} catch { // → ¡Sin binding!
handleException();
}

Soporte para binding opcional en catch