1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<%@ page language=
"java"
import=
"java.util.*"
pageEncoding=
"UTF-8"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+
"://"
+request.getServerName()+
":"
+request.getServerPort()+path+
"/"
;
%>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
>
<html>
<head>
<base href=
"<%=basePath%>"
>
<title>My JSP
'test3.jsp'
starting page</title>
<meta http-equiv=
"pragma"
content=
"no-cache"
>
<meta http-equiv=
"cache-control"
content=
"no-cache"
>
<meta http-equiv=
"expires"
content=
"0"
>
<meta http-equiv=
"keywords"
content=
"keyword1,keyword2,keyword3"
>
<meta http-equiv=
"description"
content=
"This is my page"
>
<!--
<link rel=
"stylesheet"
type=
"text/css"
href=
"styles.css"
>
-->
<script src=
"js/jquery-2.1.1.min.js"
></script>
<script>
//函数参数
//js的参数:形参,实参
function
test(a,b){
//alert(test.length); //参数名.length可以得到函数参数个数(并不一定等同于实际传入的参数个数)
//函数的实际参数 内部是通过数组的形式接收实际参数
//arguments对象可以访问函数的实际参数 arguments只能在函数内部使用
//alert(arguments.length); //返回实际传入的参数
//alert(arguments[0]);
//alert(arguments[1]);
// if(arguments.length===test.length){
// return a+b;
// }else{
// return '参数不正确';
// }
//arguments对象用的做多的还是递归操作 arguments.callee指向函数本身
alert(arguments.callee.length);
//arguments.callee.length得到的值和函数名.length值相同,但是arguments.callee.lenth更好
return
a+b;
}
//alert(test(1,2)); //3
//alert(test(1,2,3,4)); //3
//alert(test()); //NaN
function
fact(num){
if
(num<=1){
return
1;
}
else
{
//return num*fact(num-1);
return
num*arguments.callee(num-1);
//等同于return num*fact(num-1);
}
}
var
F=fact;
alert(fact(5));
fact=
null
;
//如果此处fact=null,函数写成return num*fact(num-1);会报错,但return num*arguments.callee(num-1); 正确
alert(F(5));
</script>
</head>
<body>
This is my JSP page. <br>
</body>
</html>
|
本文转自 matengbing 51CTO博客,原文链接:http://blog.51cto.com/matengbing/1879001