0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScript: try/catchでエラーが起きても処理を中止させない方法

Last updated at Posted at 2020-02-01

tryを使うと、まずは処理を恐る恐る実行し、catchでそのエラーを受けた処理をしつつも、そのまま先に処理を進めてくれる。


'use strict';


const name = 1;

try {
    console.log(name.toUpperCase()); // エラーが起きる
} catch (e) {
    console.log(e); // eで取得したエラー内容を表示する
}

console.log('Bye.'); // そして、ここまで来る。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?