标签:turn name http state parameter argument 显示 nbsp html
1 function functionName(parameter1, parameter2, ... ) { 2 statements 3 }
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>使用函数</title> 5 </head> 6 <body> 7 <script type="text/javascript"> 8 function Hello() { 9 document.write("hello,"); 10 } 11 function Message(message) { 12 document.write(message); 13 } 14 Hello(); 15 Message("javascript!"); 16 </script> 17 </body> 18 </html>
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>使用arguments数组</title> 5 </head> 6 <body> 7 <script type="text/javascript"> 8 function displayArguments() { 9 document.write("此函数使用了以下参数:<br>") 10 for (i = 0; i < arguments.length; i++) { 11 document.write(i+"="+arguments[i]+"<br>") 12 } 13 } 14 displayArguments(21,"cat",-2000,"tiger","great"); 15 </script> 16 </body> 17 </html>
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>函数的返回值</title> 5 </head> 6 <body> 7 <script type="text/javascript"> 8 function add(a,b) { 9 return a+b; 10 } 11 document.write("3 + 5 =" +add(3,5)); 12 </script> 13 </body> 14 </html>
标签:turn name http state parameter argument 显示 nbsp html
原文地址:http://www.cnblogs.com/luckyliulin/p/7388959.html