Skip to content

Commit fe79a1e

Browse files
committed
add: scope
1 parent 9f548c7 commit fe79a1e

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

01-Basics/06-scope/app.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// var
2+
const c = 3;
3+
// c = 'abc';
4+
5+
function varTest(){
6+
var x = 0;
7+
console.log(x);
8+
9+
if(true){
10+
var x = 1;
11+
console.log(x); // 1
12+
}
13+
14+
// var x = 2;
15+
console.log(x); // 1
16+
}
17+
18+
19+
// let
20+
21+
function letTest(){
22+
let y = 0;
23+
console.log(y);
24+
25+
if(true){
26+
let y = 1;
27+
console.log(y); // 1
28+
}
29+
30+
// let y = 2;
31+
console.log(y); // 0
32+
}

01-Basics/06-scope/app2.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let name = 'Walker';
2+
var z = 'zet'

01-Basics/06-scope/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Learning JavaScript - Walker</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
<h1>Scope</h1>
10+
<script src="app.js"></script>
11+
<script src="app2.js"></script>
12+
</body>
13+
</html>

01-Basics/06-scope/style.css

Whitespace-only changes.

0 commit comments

Comments
 (0)