DEV Community

Discussion on: JavaScript 101: Arrow Functions

Collapse
 
drozerah profile image
Drozerah • Edited

Implicit return:

When returning an Object, remember to wrap the curly brackets in parentheses to avoid it being considered the default wrapping function body brackets:

const myFunction = () => ({value:'test'})

console.log(myFunction()) // { value: 'test' }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
c24w profile image
Chris Watson

And remember to write tests so you catch these mistakes :)

Collapse
 
drozerah profile image
Drozerah • Edited

We wish to read you about tests - from scratch - if you have time to start a serie about that topic... ;)