Sometimes, we want to return values in JavaScript.
In this article, we’ll look at how to return values in JavaScript.
How to return values in JavaScript?
To return values in JavaScript, we use the return statement.
For instance, we write
const myFunction = (value1, value2, value3) => {
return { val2: value2, val3: value3 };
};
to define the myFunction function.
It takes 3 parameters.
And we put value2 and value3 in an object and return the object.
Conclusion
To return values in JavaScript, we use the return statement.