Promise.finally

finally — A callback for a completed Promise.

Description

Promise.finally()

Changelog

Version Description
ES 6 Introduced.

Examples

Example #1 – Nested example
new Promise((resolve, reject) => { // Randomly resolve or reject the promise. if (Math.random() >= 0.5) { resolve('resolved! :)'); } reject('rejected :('); }).then(result => { console.log(result); }).catch(error => { console.log(error); }).finally(() => { console.log('Finally!'); });

External references