VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-promise-finally-method/

⇱ JavaScript Promise finally() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Promise finally() Method

Last Updated : 23 Jul, 2025

The finally() method of the Promise object is used to return a callback when a Promise is settled (either fulfilled or rejected).

Syntax:

task.finally(onFinally() {
});

Parameters:

This method has a single parameter as mentioned above and described below:

  • onFinally: It is the function that will be called when the Promise is settled.

Return Value:

It returns a Promise whose finally handler is set to the specified function.

Example: The below example demonstrates the finally() method:

Output:

Error: Promise has been rejected!
This is finally() block that is executed after Promise is settled

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
Comment