JavaScript Promise.finally() Explained

JavaScript Logo

Promise.finally() – `finally()` runs regardless of promise success or failure. Useful for cleanup tasks like hiding loaders.

๐Ÿ‘‰ Syntax

promise.finally(() => {
  // cleanup or final step
});

๐Ÿงช Example

fetch('/some-api')
  .finally(() => console.log('Done loading'));

Comments