Defining Functions That Return Results - Javascript Language Basics

Javascript examples for Language Basics:Introduction

Introduction

You can return results from functions using the return keyword.

Demo Code

ResultView the demo in separate window

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <script type="text/javascript">

            function myFunc(name) {
                return ("Hello " + name + ".");
            };/*from  w ww. j a v a  2  s.c  om*/

            document.writeln(myFunc("java2s.com"));
        </script>
    </body>
</html>

Related Tutorials