โคด๏ธtry-catch-finally

๐Ÿšง under construction

(statement)

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