JavaScript · Senior · Question 53 of 75
What problem does Promise.try(fn) solve?
- ✓Correct answer: It runs
fnand turns both sync throws and async rejections into a rejected promise - 2It retries
fnuntil it succeeds - 3It runs
fnin a worker
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.