How do promises solve inversion of control in JavaScript?
Promises guarantee once-only settlement (resolve or reject exactly once), async execution (.then callbacks run as microtasks), and value-or-error delivery. You trust the promise spec, not the function calling the callback.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Inversion of Control in JavaScript Callbacks
When you pass a callback to a function, you give up control of when and how it is called. The function might call it multiple times, not at all, too early, or with wrong arguments. You are trusting the function to behave correctly.
The function might call the callback multiple times (duplicate effects), zero times (page hangs), too early (before setup is done), with wrong arguments (undefined), or synchronously when you expected async.
Yes. async/await is built on promises, so it has the same guarantees: once-only settlement, async execution, and value-or-error delivery. You trust the promise spec, not the function.
Still have questions?
Browse all our FAQs or reach out to our support team
