46 lines
994 B
HTML
46 lines
994 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
// 浏览器顶级对象==>window
|
|
// 页面顶级对象==>Document
|
|
// 变量是属于 window 的,在内存中 ,存储
|
|
// 堆==>引用类型
|
|
// 栈==>值类型
|
|
var str = 'hello'
|
|
console.log(str)
|
|
console.log(window.str)
|
|
|
|
function f1(){
|
|
console.log('hello word')
|
|
}
|
|
f1()
|
|
window.f1()
|
|
|
|
//注意
|
|
var name = "战三"
|
|
console.log(name)
|
|
console.log(window.name)
|
|
|
|
var number
|
|
console.log(number)//变量声明未赋值==>返回undefined
|
|
console.log(window.number)
|
|
|
|
console.log(top)
|
|
console.log(window)
|
|
// top===>>window
|
|
|
|
window.alert(111)
|
|
//window.的东西都可以省略window
|
|
var res = window.confirm('确定退出么?')
|
|
console.log(res)//===>返回值true false
|
|
var res = window.prompt('请输入密码',8888)
|
|
console.log(res)//返回输入的内容,,返回值字符串
|
|
|
|
</script>
|
|
</body>
|
|
</html> |