Do arrow functions with block bodies return undefined if there is no return statement?
Yes. An arrow with a block body (=> { ... }) needs an explicit return. Without it, the function returns undefined. Only an arrow with an expression body (=> expr) returns the expression implicitly.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in undefined in Function Parameters and Returns in JavaScript
The missing parameters are set to undefined. You can handle this with default parameters, which apply only when the argument is undefined or omitted.
No. Defaults apply only when the argument is undefined or omitted. Passing null, 0, or empty string does not trigger the default, because those are real values.
undefined. If a function has no return, or a return with no expression, it returns undefined to the caller.
Still have questions?
Browse all our FAQs or reach out to our support team
