メインコンテンツまでスキップ

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

· 約1分
Mathias Bynens ([@mathias](https://twitter.com/mathias))

try文のcatch句は以前はバインディングが必要でした:

try {
doSomethingThatMightThrow();
} catch (exception) {
// ^^^^^^^^^
// バインディング名を付ける必要があります、たとえそれを使用しなくても!
handleException();
}

ES2019では、catchバインディングなしで使用可能になりました。この機能は、例外を処理するコードでexceptionオブジェクトが必要ない場合に便利です。

try {
doSomethingThatMightThrow();
} catch { // → バインディングなし!
handleException();
}

オプションのcatchバインディング対応状況