JavaScript · Senior · Question 37 of 75
What does Promise.withResolvers() (ES2024) give you?
- ✓Correct answer: Returns
{ promise, resolve, reject }for control from outside - 2Creates a promise that can't be rejected in any way
- 3Automatically cancels the promise after a given timeout
Explanation
Previously you wrote a "deferred" for this: declared variables and assigned resolve/reject inside the constructor. Handy when a promise is resolved from elsewhere - for example, from an event handler or a queue.