Returning Values : Function Return « Function « JavaScript Tutorial






JavaScript provides a return statement to return a value.

The value to be returned is placed after the keyword return.

The 'undefined' value is returned from a function if no value is specified after the keyword return or if the return statement is not used.

A value returned from a function can be assigned to a variable or used within an expression.

<html>
<SCRIPT LANGUAGE='JavaScript'>
    <!--
    function multiplyByFive(aNumber)
    {
      return aNumber*5;
    }
    document.write("3*5=",multiplyByFive(3));
    //-->
</SCRIPT>
</html>








7.7.Function Return
7.7.1.return
7.7.2.Returning Values
7.7.3.Return value from a function
7.7.4.Return boolean value from function
7.7.5.Return an array from a function