JavaScript Promise finally()

Definition and Usage

finally() The method provides a callback function.

The callback is a function that will execute when a Promise is settled (either fulfilled or rejected).

Example

myPromise.finally(() => myDisplay("Completed"));

Try It Yourself

Syntax

promise.finally(settled())

Parameters

Parameters Description
settled() A function to be executed when a Promise is settled (fulfilled or rejected).

Return Value

Type Description
Object New Promise object.

Browser Support

finally() It is a feature of ECMAScript 2018.

Since June 2020, ES2018 has been supported in all modern browsers:

Chrome Edge Firefox Safari Opera
Chrome 63 Edge 79 Firefox 78 Safari 12 Opera 50
December 2017 January 2020 June 2020 September 2018 January 2018

finally() Does not support Internet Explorer.