Difficulty: 5/10error handling, resource cleanup, promise chainingThe .finally() method is used to attach a callback that will be executed regardless of whether the Promise is fulfilled or rejected.javascriptCopyScenario Questions0-2 years experience1You need to fetch user data and then hide a loading spinner regardless of success or failure. How would you use Promise.finally() to ensure the spinner is hidden?2If you have a promise that resolves, and you attach a finally handler that returns a value, what will the downstream then receive?2-5 years experience1We have a function that retries an API call up to three times on failure. After all attempts, we need to log the duration of the whole operation. How would you incorporate Promise.finally() into the retry logic, and what pitfalls might you watch out for?Follow-up QuestionsWhat happens if the finally callback returns a rejected promise?Can you use finally with async/await syntax, and how does it differ from a try/finally block?How does finally affect the propagation of the original error or value?Suggest Improvement