Suggest an editImprove this articleRefine the answer for “What happens if you omit await”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**Without `await` you get the `Promise` itself instead of the result: a promise that will settle some day but has not settled yet.** Execution is not suspended, the code moves on, and the function keeps running in the background. That is why `user.name` is `undefined`, and `try...catch` misses the rejection, because you never waited for it. Sometimes this is deliberate: you start tasks in parallel and wait for them with `Promise.all`. ```javascript const result = getData(); // Promise { 'Data' } const value = await getData(); // 'Data' ``` **Key point:** without `await` you create a promise and move on instead of waiting for the result.Shown above the full answer for quick recall.Answer (EN)Image**If you omit `await`, you get the `Promise` itself instead of the result: a promise that will settle some day but has not settled yet.** Without `await` you do not wait for the result, you simply create a promise and move on. ## Theory ### TL;DR - Calling an `async` function without `await` returns a `Promise`, not a value. - Execution is not suspended: the code moves on at once and the function runs in the background. - Reading a field of the result (`user.name`) gives `undefined`; that is a logic bug, not a syntax error. - `try...catch` will not catch a `reject` if you did not `await` it. - Sometimes omitting `await` is correct: tasks start in parallel and are awaited with `Promise.all`. - `return await promise` in a plain `return` is redundant, `async` wraps the result anyway. ### Quick example ```javascript async function getData() { return 'Data'; } async function main() { const withoutAwait = getData(); // Promise { 'Data' } const withAwait = await getData(); // 'Data' console.log(withoutAwait, withAwait); } main(); ``` ### Without await the variable holds a promise **Example 1, without `await` a promise is returned** ```javascript async function getData() { return 'Data'; } async function main() { const result = getData(); // no await console.log(result); } main(); ``` Output: ```text Promise { 'Data' } ``` Why: - `getData()` is an `async` function, so it **always returns a promise**; - without `await` you get a **Promise object**, not `'Data'`. **Example 2, with `await`** ```javascript async function main() { const result = await getData(); // waited for it console.log(result); } main(); ``` Output: ```text Data ``` `await` "unwraps" the promise and returns its value. ### The code moves on without waiting **Example 3, no `await`, so the code ran ahead** ```javascript async function delay() { await new Promise(res => setTimeout(res, 2000)); console.log('Finished after 2 seconds'); } async function run() { delay(); // we do not wait! console.log('Moving on'); } run(); ``` Output: ```text Moving on Finished after 2 seconds ``` Without `await` execution is not suspended: `delay()` is started **in the background** while the program moves on. **Example 4, a missing `await` gives the wrong result** ```javascript async function fetchUser() { return { name: 'Alex' }; } async function showUser() { const user = fetchUser(); // forgot await console.log('User name:', user.name); } showUser(); ``` Output: ```text User name: undefined ``` Because `user` is not an object but a **Promise**, which has no `name` field. So it is a logic bug, not a syntax error. ### When await is left out on purpose **Example 5, parallel tasks.** Sometimes **omitting `await` is the right thing**, when you want to start operations in parallel: ```javascript async function load() { const userPromise = fetch('/api/user'); const postsPromise = fetch('/api/posts'); // wait for both in parallel const [user, posts] = await Promise.all([userPromise, postsPromise]); console.log('Both responses received'); } ``` Had you put `await` right after each `fetch`, they would run **one after another** instead of at the same time. **Example 6, no `await` when returning** ```javascript async function foo() { return await Promise.resolve('OK'); } ``` Here `await` is **redundant**, you can simply write: ```javascript async function foo() { return Promise.resolve('OK'); } ``` because an `async` function **wraps the result in a promise anyway**. ### Under the hood: what really happens When you call an `async` function: ```javascript const p = myAsyncFunction(); ``` JavaScript **immediately** returns a `Promise` object, while the code inside starts running asynchronously. If you do not put `await`, that promise simply hangs "in the air", and you never use the result of its work. ### Common problems without await | Mistake | What happens | | --- | --- | | Forgot `await` when calling an async function | The variable holds a `Promise`, not the result | | Returning without `await` inside another async | May return an "unfinished" promise | | Inconsistent data | The code moves on while the promise has not settled | | Errors are not caught | `try...catch` misses the `reject` because you never awaited it | > Think of `await` as "waiting for your order": > > - with `await`: you stand at the counter, wait for the coffee and get your cup; > - without `await`: you just placed the order and walked away, the coffee gets made but you never picked it up. | Scenario | What happens | | --- | --- | | `await` omitted | The function returns a `Promise` and execution continues at once | | `await` used | Execution is suspended until the promise settles | | An error without `await` | `try...catch` misses it, the promise was never awaited | | When not to use `await` | When starting parallel tasks (`Promise.all`) | ### Common mistakes - **Reading fields of the result without `await`.** `user.name` on a promise is always `undefined`, and you get no error at all. - **Relying on `try...catch` without `await`.** The block finishes before the promise rejects, and you end up with an unhandled rejection. - **Forgetting `await` in a `return` inside `try`.** The error is caught by the caller, not by the local `catch`. - **Putting `await` in front of every independent request.** Parallel operations should start without `await` and be collected with `Promise.all`. - **Assuming that without `await` the function does not run.** It starts immediately, nobody is just waiting for its result.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.