オプションの catch バインディング

公開 · タグ: ECMAScript ES2019

try ステートメントの catch 句ではバインディングが必要でした

try {
doSomethingThatMightThrow();
} catch (exception) {
// ^^^^^^^^^
// We must name the binding, even if we don’t use it!
handleException();
}

ES2019 では、catch はバインディングなしで 使用できます。例外を処理するコードで exception オブジェクトが必要ない場合に役立ちます。

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

オプションの catch バインディング サポート #