Categories
JavaScript Answers

How to return values in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *