In JavaScript, you can return a value from an arrowfunction just like you would with a regular function. Arrow functions allow you to create concise one-liners for returning a value. Here's how you can return a value from an arrow function:
const functionName = (parameter1, parameter2, ...) => {
// Function body
return returnValue; // Return statement
};
Arrow functions are especially useful for short, single-expression functions, as they allow you to omit the curly braces
{} and write the expression directly after the =>, making the code more concise. For such functions, you can return a value without using the
return keyword explicitly, like this:
const addNumbers = (num1, num2) => num1 + num2;
This is known as an implicit return, and it works when the function body consists of a single expression.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In JavaScript, you can return a value from an arrow function just like you would with a regular function. Arrow functions allow you to create concise one-liners for returning a value. Here's how you can return a value from an arrow function:
Arrow functions are especially useful for short, single-expression functions, as they allow you to omit the curly braces {} and write the expression directly after the =>, making the code more concise. For such functions, you can return a value without using the return keyword explicitly, like this:
This is known as an implicit return, and it works when the function body consists of a single expression.