-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.html
More file actions
42 lines (35 loc) · 839 Bytes
/
function.html
File metadata and controls
42 lines (35 loc) · 839 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
/*
function show(){
return 12;
}
var a = show();
alert(show());
alert(a);
*/
//函数定义
function sum(a, b) {
return a + b;
}
alert(sum(1, 2));
//arguments 可变参数/不定参数
//arguments 是一个数组,其存了所有的参数
function sumArgu() {
var result = 0;
for (var i = 0; i < arguments.length; i++) {
result += arguments[i];
}
return result;
}
alert(sumArgu(12, 4, 3, 5, 3));
</script>
</head>
<body>
</body>
</html>