匿名异步函数调用

Mur*_*ami 5 javascript ecmascript-6

是否可以创建匿名异步函数?

当然,命名函数可以工作:

const test = async() => {
 await ... //fetch some data
}
Run Code Online (Sandbox Code Playgroud)

但是未命名异步函数的工作语法是什么?这里我们应该使用IIFE来调用它吗?

For*_*vin 2

const test = async (asyncFunc) => {
    return await asyncFunc()
}

test(async () => { 
    return "Hello World!"
}).then(console.log)
Run Code Online (Sandbox Code Playgroud)