There is another option to return something without the return key word, you can wrap the curly brace with parentheses () and this will signal the engine that the curly brace are not a function body but an object, this is considered as creating an expression:
const x = () => ({myKey: 'some string'});
This is similar as we usually do with function expressions.
Especially with IIFE (Immediately Invoked Function Expression) :
(function() {
//some logic...
})();
If we will not return anything, then the function will just return undefined.
Arrow functions can return a value implicitly or explicitly. When there is no function body (no curly brace {}) then you are returning implicitly:
When we use a function body, we need to use the return key word:
There is another option to return something without the return key word, you can wrap the curly brace with parentheses () and this will signal the engine that the curly brace are not a function body but an object, this is considered as creating an expression:
This is similar as we usually do with function expressions. Especially with IIFE (Immediately Invoked Function Expression) :
If we will not return anything, then the function will just return undefined.