-
Notifications
You must be signed in to change notification settings - Fork 10
/
34.变量提升练习题.html
51 lines (45 loc) · 1.03 KB
/
34.变量提升练习题.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
//案例1:
// var num = 123;
// function f1() {
// console.log( num );
// }
// function f2() {
// num = 456;
// f1();
// }
// f2(); //456
//案例2:
// var arr = [];
// for(var i = 0; i < 10; i++){
// arr.push(i);
// }
//
// for (var i = 0; i < 10; i++) {
// console.log(arr[i]); //依次输出0,1,2,3,4,5,6,7,8,9
// }
//案例3:
// function foo() {
// var num = 123;
// console.log(num); //123
// }
// foo();
// console.log(num); //num is not defined
//案例4:
var scope = "global";
function foo() {
console.log(scope); //
var scope = "local";
console.log(scope); //
}
foo();
</script>
</head>
<body>
</body>
</html>