Which is better to do: export a const
arrow function, like so:
export const foo = () => 'bar'
or export a regular function, like so:
export function baz() {
return 'bar';
}
They compile like so:
exports.baz = baz;
function baz() {
return 'bar';
}
var foo = exports.foo = function foo() {
return 'bar';
};
It looks like using the const/arrow function combination declares an extra variable (foo
), which seems to be an unnecessary extra step over the simple function declaration.