# Async Immediately Invoked Function Expression (iife) syntax simplificaton

**URL:** <https://es.discourse.group/t/async-immediately-invoked-function-expression-iife-syntax-simplificaton/2050>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [June 7, 2024, 9:15am UTC](https://es.discourse.group/t/async-immediately-invoked-function-expression-iife-syntax-simplificaton/2050 "2024-06-07T09:15:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brg](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@brg](https://es.discourse.group/u/brg)\
**Post date:** [June 7, 2024, 9:15am UTC](https://es.discourse.group/t/async-immediately-invoked-function-expression-iife-syntax-simplificaton/2050/1 "2024-06-07T09:15:08Z")

</div>

Hi  
I have this idea - I'm not sure if it's possible to actually implement, but I still want it to suggest

So basically if I'm not in async function context, and I have to make multiple async function calls in specific order, I have two options:

```javascript
asyncFunction().then(...)

```

or

```javascript
(async function() {
    // ... await asyncFunction() ...
})();

```

I'm not a big fan of `.then()`, especially if there are two or three callbacks in a chain, so I would almost always stick with second option.  
So, my suggestion is to have this syntactic sugar for that option, like this:

```javascript
async {
    // ... await asyncFunction() ...
}

```

* * *

The drawback I'm aware of - it will be impossible to give a name for such "anonymous function", like that:

```javascript
(async function usefulNameForDebugging() {
    // ... await asyncFunction() ...
})();

```

it's very useful for debugging purposes

* * *

PS I'm aware of top-level await thing, but it I'm mostly working with JS frameworks, so I'm not actually controlling code execution, I'm facing this need to wait for async calls not on the top-level

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [June 7, 2024, 9:46am UTC](https://es.discourse.group/t/async-immediately-invoked-function-expression-iife-syntax-simplificaton/2050/2 "2024-06-07T09:46:49Z")

</div>

I think you would be interested in [GitHub - tc39/proposal-async-do-expressions: async `do` expressions for JavaScript](https://github.com/tc39/proposal-async-do-expressions)
