Implicit return means a function returns a value without using the return keyword explicitly.
This happens in arrow functions when the function body is a single expression and does not use {}.
Example
Implicit return:
const add = (a, b) => a + b;
This automatically returns a + b.
Explicit return:
const add = (a, b) => {
return a + b;
};
Key rule
- ✅ No
{}→ implicit return - ❌
{}used → must usereturn
In JSX (very common in React)
const Item = () => <div>Hello</div>;
Equivalent to:
const Item = () => {
return <div>Hello</div>;
};
In short:
Implicit return = JavaScript returns the expression for you.
Top comments (0)