JavaScript · Senior · Question 53 of 75

What problem does Promise.try(fn) solve?

Explanation

Promise.resolve().then(fn) delays execution to a microtask, and new Promise(r => r(fn())) is verbose. Promise.try runs synchronously but still gives uniform error handling.

Further reading

Problem with a question

JavaScript · Senior · question 53

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