JavaScript · Senior · Question 37 of 75

What does Promise.withResolvers() (ES2024) give you?

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.

Further reading

Problem with a question

JavaScript · Senior · question 37

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz