# Zero-operand await

**URL:** <https://es.discourse.group/t/zero-operand-await/248>\
**Category:** 💡 Ideas\
**Created:** [February 29, 2020, 4:07pm UTC](https://es.discourse.group/t/zero-operand-await/248 "2020-02-29T16:07:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyearnshaw](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/andyearnshaw/32/259_2.png) [@andyearnshaw](https://es.discourse.group/u/andyearnshaw)\
**Post date:** [February 29, 2020, 4:07pm UTC](https://es.discourse.group/t/zero-operand-await/248/1 "2020-02-29T16:07:59Z")

</div>

Quite often I find myself writing `await Promise.resolve()` in an async function, particularly when writing tests for other async functions but also sometimes when I just want to delay execution until the next tick. The thing about this is that I know I can write `await null`, `await 1` or `await (expression)` for much the same effect. However, I feel like the intention is not as clear with these other things, and I work with and mentor junior engineers who I know would be confused by it because you're awaiting a non-asynchronous value. So I choose the overly verbose option for increased clarity.

Would it be feasible to make the expression `await;` work on its own as syntactic sugar for `await undefined;`?

---

<div class="post-metadata">

**Author:** ![claudepache](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudepache/32/236_2.png) [@claudepache](https://es.discourse.group/u/claudepache)\
**Post date:** [March 2, 2020, 1:10am UTC](https://es.discourse.group/t/zero-operand-await/248/2 "2020-03-02T01:10:24Z")

</div>

If `await null` is not clear enough, I suggest adding a comment:

```javascript
await null; // delay execution until the next tick

```

---

<div class="post-metadata">

**Author:** ![andyearnshaw](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/andyearnshaw/32/259_2.png) [@andyearnshaw](https://es.discourse.group/u/andyearnshaw)\
**Post date:** [March 2, 2020, 3:04pm UTC](https://es.discourse.group/t/zero-operand-await/248/3 "2020-03-02T15:04:56Z")

</div>

Yeah I could do that, I guess. Just thinking something that doesn't need clarification with a comment (because it would be suitably explained by most documentation) would be better.

---

<div class="post-metadata">

**Author:** ![bergus](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bergus/32/152_2.png) [@bergus](https://es.discourse.group/u/bergus)\
**Post date:** [March 3, 2020, 9:08pm UTC](https://es.discourse.group/t/zero-operand-await/248/4 "2020-03-03T21:08:13Z")

</div>

Hello!

> [@andyearnshaw](#):
>
> Quite often I find myself writing `await Promise.resolve()` in an async function, particularly when writing tests for other async functions but also sometimes when I just want to delay execution until the next tick.

Can you give some specific examples where you think this is necessary? I hardly ever found `await null` to be useful. It doesn't really delay to the next tick of the event loop, it's just a microtask, and `while (true) { await null }` still blocks your application. If there's a need to wait for something, one should always explicitly spell out what to wait for. Even if "wait for one microtick" sometimes works.
