Skip to content

Commit 5fd2936

Browse files
[ADD] 在BOM中添加window
1 parent 7c373b0 commit 5fd2936

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

BOM/window.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>window</title>
6+
</head>
7+
<body>
8+
<script>
9+
//var定义的变量会被添加到全局对象
10+
var varVariable="varVariable";
11+
//let定义的变量不会被添加到全局对象
12+
let letVariable="letVariable";
13+
function sayHi(){
14+
alert("Hi, window");
15+
}
16+
//弹窗显示varVariable
17+
alert(window.varVariable);
18+
//弹窗显示undefined
19+
alert(window.letVariable);
20+
window.sayHi();
21+
</script>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)