Source @ github

try … catch … finally

try … catch … finally

Description

try { mixed code, mixed catch, mixed finally } … catch … finally

Parameters

Name Description Type Default Optional
code mixed No
catch catch, finally or both needs to is reqired. mixed
finally catch, finally or both needs to is reqired. mixed

Examples

Example #1 – if … else example
try { console.log(abc); } catch (e) { console.log(e); // ReferenceError: abc is not defined(…) }
try { console.log(abc); } catch (e) { console.log(e); // ReferenceError: abc is not defined(…) } finally { console.log('Finally.'); // Finally will be run regardless of errors caught. }

External references