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?

3
  • 1
    Check this one Commented Apr 2, 2018 at 9:15
  • oh, thanks, should we close this one? Commented Apr 2, 2018 at 9:18
  • I'll flag as duplicate or you can delete Commented Apr 2, 2018 at 9:19

1 Answer 1

0

You can try this code:

const foo = async () => {
  // do something here
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.