1

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
  • 2,166
  • 19
  • 100
  • 200

1 Answers1

0

You can try this code:

const foo = async () => {
  // do something here
}
trinaldi
  • 2,872
  • 2
  • 32
  • 37
huydq5000
  • 274
  • 1
  • 8