What is the use of return statement inside a function in JavaScript?


The “return” statement in JavaScript mentions a value, which you like to return. Inside a function, the value is returned to the function caller.

Example

You can try to run the following code to implement return statement inside a function

Live Demo

<html>
   <body>
      <script>
         function multiply(num1, num2) {
            return num1 * num2;
         }
         var result = multiply(5, 10);
         document.write("Multiplication: "+result);
      </script>
   </body>
</html>

Updated on: 07-Jan-2020

213 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements