Monday, June 3, 2024
147
rated 0 times [  151] [ 4]  / answers: 1 / hits: 108889  / 8 Years ago, wed, april 6, 2016, 12:00:00

The export statement below gives a syntax error



export default const hello = () => console.log(say hello)


why ?



I'm only able to export named functions



export function hello() {
console.log(hello)
}


What is the reason?


More From » ecmascript-6

 Answers
109

Is it possible to export Arrow functions in ES6/7?




Yes. export doesn't care about the value you want to export.




The export statement below gives a syntax error ... why?




You cannot have a default export and give it a name (default is already the name of the export).



Either do



export default () => console.log(say hello);


or



const hello = () => console.log(say hello);
export default hello;

[#62668] Monday, April 4, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
coleman

Total Points: 518
Total Questions: 81
Total Answers: 96

Location: Aland Islands
Member since Wed, Nov 17, 2021
3 Years ago
;