Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

catch(e){} 是什麼意思?

我看 Javascript 的敘述 裡面有個

catch(e){}

請問是什麼意思 何時用的到?

2 Answers

Rating
  • 爵士
    Lv 5
    1 decade ago
    Favorite Answer

    Debug 或是 防止某支Javascript 函數或敘述 錯誤發生時

    擷取它,告知 user 或管理者處理

    如同 Java 程式之例外處理模式

  • 吉他
    Lv 5
    1 decade ago

    那是try-catch例外處理,用來補抓某一段在try-catch程式碼裡有不可預期的錯誤產生時,會拋出一個例外物件,而catch就會接收被拋出來的錯誤物件,可以利用該物件取得一些錯誤訊息

Still have questions? Get your answers by asking now.