Standard built-ins

Promise.prototype.finally()

Try the free JavaScript compiler

Attaches outcome-independent cleanup. Successful cleanup normally preserves the earlier outcome, while a thrown error or rejection replaces it.

Formal Syntax & Structure

javascript syntaxjavascript
promise.finally(onFinally)

Parameters & Attributes

NameTypeDescription
onFinallyfunctionInvoked without outcome arguments.

Return Value

Promise

Downstream promise after cleanup.

Working Example

Example Snippetjavascript
Promise.resolve(5).finally(()=>9).then(console.log);
JavaScript Reference