Javascript examples for Language Basics:Introduction
You can return results from functions using the return keyword.
<!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>