Statements

finally clause

Try the free JavaScript compiler

Executes on normal and abrupt exits from the protected block. Normal finally completion preserves a pending return or throw; an abrupt completion overrides it.

Formal Syntax & Structure

javascript syntaxjavascript
try { work(); } finally { cleanup(); }

Working Example

Example Snippetjavascript
function f(){try{return 1;} finally{console.log("clean");}} console.log(f());
JavaScript Reference