0

When defining an asynchronous function I normally go for

async function myFunc(){
 // ...
}

I would like to switch over to lambda expressions. I tried

async myFunc() => { // throws an syntax error
 // ...
}

and

myFunc = async () => { // weird things come up
 // ...
}

I think the second example does not work because this code would try to store the functions result into myFunc like

let myFunc = f(); // store the result

Is it possible to define functions with lambda expressions or are they only used within other functions?

Question3r
  • 1,184
  • 10
  • 68
  • 156

1 Answers1

0

You can try this code:

const foo = async () => {
  // do something here
}
Tico
  • 2,784
  • 2
  • 33
  • 36
huydq5000
  • 264
  • 1
  • 8