Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  52] [ 5]  / answers: 1 / hits: 42563  / 8 Years ago, wed, october 19, 2016, 12:00:00
export default async function () {

};


or



export default async () => {

};


Which one is preferred when exporting a default function and why?


More From » node.js

 Answers
16

The first one is generally preferred. It's a declaration, not an expression value, which has subtle advantages. And it can easily be named if you want, which is a good practice. Also, arrow functions have a few disadvantages in certain situations, so unless you absolutely need them to preserve a this value (etc.) you'd rather avoid them. Saving 5 characters to type is hardly worth it.


[#60346] Sunday, October 16, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
giovanny

Total Points: 314
Total Questions: 101
Total Answers: 90

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;