The new es6 arrow functions say return
is implicit under some circumstances:
The expression is also the implicit return value of that fun
Arrow functions allow you to have an implicit return: values are returned without having to use the return
keyword.
It works when there is a on-line statement in the function body:
const myFunction = () => 'test'
console.log(myFunction()) //'test'
Another example, returning an object (remember to wrap the curly brackets in parentheses to avoid it being considered the wrapping function body brackets):
const myFunction = () => ({value: 'test'})
console.log(myFunction()) //{value: 'test'}