Standard built-ins
Promise.prototype.finally()
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
| Name | Type | Description |
|---|---|---|
| onFinally | function | Invoked without outcome arguments. |
Return Value
Promise
Downstream promise after cleanup.
Working Example
Example Snippetjavascript
Promise.resolve(5).finally(()=>9).then(console.log);