<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
//1.变量没声明,直接赋值了
// function fn() {
// num = 10 //看做全局变量 强烈不推荐
// }
// console.log(num)
function fun(x, y) {
//2.形参看成函数的局部变量
console.log(x)
}
fun(1, 2)
// console.log(x) //错误的
// 3.套娃函数(自取)---采用就进原则找最终值
function fn(){
let num = 20
function fun(){
let num = 30
console.log(num)
}
fun()
}
fn()
</script>
</body>
</html>
09_变量的特殊情况
最新推荐文章于 2024-07-22 15:13:59 发布