JS Built-ins
AsyncPatternsbeginner

.finally returns a Promise

πŸ“– Usage Example
const p = Promise.resolve(1).finally(() => console.log('done'));
// logs 'done', then resolves to 1

.finally() runs cleanup regardless of resolve or reject, passing the value through.

Promise.finally()

.finally() runs a callback after the Promise settles (resolve or reject) and returns a Promise.

Challenge: Verify that .finally() returns a Promise instance.

πŸ’‘ Hints (3)
  • β€’ .finally() returns a new Promise.
  • β€’ The callback runs regardless of resolution or rejection.
  • β€’ The callback does not receive the value or reason.