747 views
What happens if I use the await operator on a non-promise value?
AI answer
The value will be immediately resolved and returned without waiting. This is equivalent to Promise.resolve(value).
Similar questions
- How do async/await work in JavaScript?
- In the given code, can you catch an exception with try/catch? How to properly handle a rejected Promise without await?
- Why can't Promise be completely replaced by async/await? In what situations is async/await not suitable?
- What is the difference between Promise and async/await? Why was async/await invented?
- What happens if errors are not handled in a Promise (no .catch)?