What happens if you don't use await?
The key idea
If you don't use await, then instead of the result you get the Promise itself,
a promise that will settle eventually, but hasn't yet.
Without
awaityou don't "wait" for the result, you just create a promise and move on.
Example 1: without await, a promise is returned
async function getData() {
return 'Data';
}
async function main() {
const result = getData(); // without await
console.log(result);
}
main();Output:
Promise { 'Data' }Why:
getData()is anasyncfunction, so it always returns a promise;- without
awaityou get a Promise object, not'Data'.
Example 2: with await
async function main() {
const result = await getData(); // waited for it
console.log(result);
}
main();Output:
Dataawait "unwraps" the promise, returning its value.
Example 3: forgot await, and the code moved on
async function delay() {
await new Promise(res => setTimeout(res, 2000));
console.log('Done after 2 sec');
}
async function run() {
delay(); // not waiting!
console.log('Moving on');
}
run();Output:
Moving on
Done after 2 secWithout await, execution doesn't pause,
the delay() function runs in the background, while the program continues.
Example 4: missing await gives the wrong result
async function fetchUser() {
return { name: 'Alex' };
}
async function showUser() {
const user = fetchUser(); // forgot await
console.log('User name:', user.name);
}
showUser();Output:
User name: undefinedBecause user is not an object, it's a Promise,
which has no name field.
That is, this is a logic error, not a syntax error.
Example 5: when you deliberately don't use await (parallel tasks)
Sometimes not using await is correct, if you want operations to run in parallel:
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');
}If you put await right after each fetch,
they would run one after another, not at the same time.
Example 6: await on a return
async function foo() {
return await Promise.resolve('OK');
}await here is redundant, you can just write:
async function foo() {
return Promise.resolve('OK');
}Because an async function wraps the result in a promise anyway.
Under the hood (what actually happens)
When you call an async function:
const p = myAsyncFunction();JavaScript immediately returns a Promise object,
while the code inside starts executing asynchronously.
If you don't use await, that promise simply stays "in the air",
and you never use the result of its execution.
Common problems without await
| Mistake | What happens |
|---|---|
Forgetting await when calling an async function | The variable ends up with a Promise, not the result |
Returning without await inside another async function | May return an "unfinished" promise |
| Inconsistent data | The code moves on while the promise hasn't resolved yet |
| Errors aren't caught | try...catch won't catch a reject if you didn't await it |
A simple analogy
Imagine
awaitis "waiting for your order"
- With
await: you stand at the counter, wait for the coffee, and get the cup.- Without
await: you just place the order and walk away, the coffee gets made, but you never pick it up.
SUMMARY
| Scenario | What happens |
|---|---|
Didn't use await | The function returns a Promise, execution continues right away |
Used await | Execution pauses until the promise settles |
An error without await | try...catch won't catch it, the promise wasn't "awaited" |
When to skip await | When launching parallel tasks (Promise.all) |
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.