โคด๏ธtry-catch-finally
๐ง under construction
JS โฉ statement โฉ control flow โฉ jump โฉ try-catch-finally
try { ... } // run code that may throw.
catch (err) { ... } // error handling (andโจ rethrow)
finally { ... } // cleanup code
ไธไฝไฝฟ็จ try
๏ผไธๅฎ่ฆ็จ catch(err)
ๅปๆใๆๆ็้ฏ่ชคใ๏ผๅฆๅๅฏ่ฝๆๆผๆใ่ชๅทฑๆฒๆ้ ๆ็้ฏ่ชคใโ
try {
noSuchFunc(); // โ ReferenceError (not catched)
} catch(err) {
// `console.log(err)` omitted ... (dangerous)โ
// or, `throw err` omitted ...
}
// the code will continue executing happilyโ
Last updated
Was this helpful?