Is using .then's second argument for error handling an anti-pattern in JavaScript?
It is less robust than .catch. .then(onFulfilled, onRejected) second arg only catches rejections from the original promise. .catch catches rejections AND thrown errors from any .then above it. Prefer .catch.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise Anti-Patterns to Avoid in JavaScript
Wrapping a promise in new Promise unnecessarily. If you already have a promise (from fetch, for example), just return it or chain .then. Wrapping it in new Promise and manually calling resolve/reject is redundant and error-prone.
Because it defeats the purpose of promises (creating mini callback hell). Instead of nesting, chain flatly. Or use async/await, which is the cleanest way to sequence async operations.
Because it is slow. If operations are independent, run them in parallel with Promise.all: const [a, b] = await Promise.all([fetchA(), fetchB()]). Sequential await is only correct when operations depend on each other.
Still have questions?
Browse all our FAQs or reach out to our support team
