JavaScript·Intermediate·Coding·1 min read
How does finally behave with async code?
Short interview answer
A finally block runs whether the try completes or throws and can itself await cleanup. If finally throws or returns a rejected promise, that new failure replaces the earlier completion, so cleanup code should be carefully designed.
Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.