Use .finally() to log 'Finished loading' after the promise is resolved.
Output:
createPromise
6 months agoCreate a promise that resolves with the message 'Done' and log it.
usePromise
6 months agoUse a promise to simulate loading user data and then log the result.
promiseFinally
6 months agoUse .finally() to log 'Finished loading' after the promise is resolved.
chainPromises
6 months agoChain multiple .then() methods to transform a number from 2 to 7.
handleError
6 months agoCatch an error if a promise is rejected and log the error message.
timeoutPromise
6 months agoWrap setTimeout in a promise to delay logging a message.
constructPromise
6 months agoConstruct a promise that rejects if the input is less than 5.
loadAllData
6 months agoUse Promise.all to wait for two async operations.
fastestPromise
6 months agoUse Promise.race to log the result of the fastest-resolving promise.