JS返回值的用法
<!DOCTYPE html> <head> <title></title> <!--js中声明函数的方法--> <script type="text/javascript"> function add(i, j) { //现在只是声明了一个函数在这里,只有调用到它的时候它才会被执行。 return i + j; } alert(add(5, 6)); //输出11 //js中并非所有路径都有返回值,如果没有返回值他就认为返回值是undefined function sum(x, y) { if (x > y) { alert(x + y); } } var z = sum(2, 6); //因为2并不大于6所以sum函数就没有返回值。如果没有返回值他就认为返回值是undefined。 alert(z); //所以它就输出了undefined </script> </head> <body> </body> </html>setTimeout用法
<!DOCTYPE html><html><head> ???<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><h1> <font color=blue> ##### </font> </h1><p> 请等三秒!</p><script>setTimeout("alert(‘对不起,要你等候多时‘)", 3000 )</script></body> </html>
明天考虑学习用setTimeout来执行functionJS的返回值,函数的运行和setTimeout的用法
原文地址:http://www.cnblogs.com/suntao12138/p/7436286.html